RInside Version 0.2.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rinside_sample5.cpp
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
2 //
3 // Another simple example inspired by an r-devel mail by Martin Becker
4 //
5 // Copyright (C) 2009 Dirk Eddelbuettel
6 // Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
7 
8 #include <RInside.h> // for the embedded R via RInside
9 
10 int main(int argc, char *argv[]) {
11 
12  try {
13  RInside R(argc, argv); // create an embedded R instance
14 
15  std::string txt = "myenv <- new.env(hash=TRUE, size=NA)";
16  R.parseEvalQ(txt); // eval string quietly, no result
17 
18  txt = "is.environment(myenv)"; // logical value assigned
19  Rcpp::LogicalVector V = R.parseEval(txt); // to logical vector
20 
21  std::cout << "We "
22  << (V(0) ? "do" : "do not")
23  << " have an environment." << std::endl;
24 
25  } catch(std::exception& ex) {
26  std::cerr << "Exception caught: " << ex.what() << std::endl;
27  } catch(...) {
28  std::cerr << "Unknown exception caught" << std::endl;
29  }
30 
31  exit(0);
32 }
33 
void parseEvalQ(const std::string &line)
Definition: RInside.cpp:366
int parseEval(const std::string &line, SEXP &ans)
Definition: RInside.cpp:308
int main(int argc, char *argv[])