rcpp - RInside: can not read R["R.version.string"] as string -


i'm trying read value of r.version.string using operator []. result exception thrown. instead, r.parseeval("r.version.string") ok. below example rinside_sample0.cpp modified showing issue.

#include <rinside.h>                    // embedded r via rinside  int main(int argc, char *argv[]) {      rinside r(argc, argv);              // create embedded r instance       try {     std::string versionko = r["r.version.string"];     } catch(std::exception& ex) {     std::cerr << "exception caught: " << ex.what() << std::endl;     } catch(...) {     std::cerr << "unknown exception caught" << std::endl;     }      std::string versionok = r.parseeval("r.version.string");     std::cout << versionok << std::endl;      r["txt"] = "hello, world!\n";   // assign char* (string) 'txt'      r.parseevalq("cat(txt)");           // eval init string, ignoring returns      exit(0); } 

the output obtained is:

exception caught: expecting string r version 3.1.2 (2014-10-31) hello, world! 

this issue has been solved on https://github.com/eddelbuettel/rinside/issues/9. variable r.version.string visible in base environment , can retrieved this:

rcpp::environment baseenv("package:base"); std::string versionr = baseenv["r.version.string"]; 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -