2

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  
Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
Manoj
  • 21
  • 1
  • I think you have no background in c.If you had before looking in console, you would realize that "gedit"(text editor) try to say something over coloring words. –  Feb 18 '11 at 08:57
  • Rember that this is not compilation of R code, only embedding it to C++ code -- this will not work faster or anything like that. – mbq Feb 18 '11 at 08:58

1 Answers1

1

You have double quote " inside double-quoted string

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

So, just escape it with backslash \, and try again.

R.parseEvalQ("fileContents<-read.csv(\"/home/nibha/manoj/test.csv\")"); 
YOU
  • 120,166
  • 34
  • 186
  • 219