2
我想使用RInside编译R代码。但是在使用函数read.csv时出现错误。下面的代码片段给出:编译RInside代码时出错
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
我认为你在c中没有背景。如果你在查看控制台之前,你会意识到“gedit”(文本编辑器)试图对着色单词说些什么。 – 2011-02-18 08:57:28
Rember认为这不是R代码的编译,只是将它嵌入到C++代码中 - 这不会更快或者类似的东西。 – mbq 2011-02-18 08:58:18