我想用RInside编译一个R代码。但我在使用函数read.csv时遇到错误。代码片段如下所示:
include "RInside.h"
include <iomanip>
include <iostream>
include <fstream>
include <string>
include <vector>
include <sstream>
using namespace std;
int main(int argc,char*argv[])
{
RInside R(argc,argv);
SEXP ans;
R.parseEvalQ("library(plotrix)");
R.parseEvalQ("fileContents<-read.csv("/home/nibha/manoj/test.csv")");
R.parseEvalQ("nr <-nrow (filecontents)");
R.parseEvalQ("nc <-ncol (filecontents)");
} 我得到的错误如下:
: In function ‘int main(int, char**)’:
prog3.cpp:14: error: ‘home’ was not declared in this scope
prog3.cpp:14: error: ‘nibha’ was not declared in this scope
prog3.cpp:14: error: ‘manoj’ was not declared in this scope
prog3.cpp:14: error: ‘test’ was not declared in this scope
prog3.cpp:20: error: ‘myfile’ was not declared in this scope 发布于 2011-02-18 16:29:28
在双引号字符串中有双引号"
R.parseEvalQ("fileContents<-read.csv("/home/nibha/manoj/test.csv")"); 因此,只需使用反斜杠\对其进行转义,然后重试。
R.parseEvalQ("fileContents<-read.csv(\"/home/nibha/manoj/test.csv\")"); https://stackoverflow.com/questions/5039056
复制相似问题