2

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  
4

1 に答える 1

1

"二重引用符で囲まれた文字列の中に二重引用符があります

R.parseEvalQ("fileContents<-read.csv("/home/nibha/manoj/test.csv")"); 

したがって、バックスラッシュ\でエスケープして、再試行してください。

R.parseEvalQ("fileContents<-read.csv(\"/home/nibha/manoj/test.csv\")"); 
于 2011-02-18T08:29:28.437 に答える