编译 RInside 代码时出错
我想使用 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
I want to compile a R code using RInside. But I am getting errors while using the function read.csv. The code snippet is given below:
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)");
}
I am getting the errors as follows:
: 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
双引号字符串中有双引号
"
因此,只需用反斜杠
\
转义它,然后重试。You have double quote
"
inside double-quoted stringSo, just escape it with backslash
\
, and try again.