RInside Version 0.2.6
inst/examples/standard/rinside_sample5.cpp
Go to the documentation of this file.
00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4;  tab-width: 8; -*-
00002 //
00003 // Another simple example inspired by an r-devel mail by Martin Becker
00004 //
00005 // Copyright (C) 2009         Dirk Eddelbuettel 
00006 // Copyright (C) 2010 - 2011  Dirk Eddelbuettel and Romain Francois
00007 
00008 #include <RInside.h>                    // for the embedded R via RInside
00009 
00010 int main(int argc, char *argv[]) {
00011 
00012     try {
00013         RInside R(argc, argv);          // create an embedded R instance 
00014 
00015         std::string txt = "myenv <- new.env(hash=TRUE, size=NA)";
00016         R.parseEvalQ(txt);              // eval string quietly, no result
00017 
00018         txt = "is.environment(myenv)";  // logical value assigned
00019         Rcpp::LogicalVector V = R.parseEval(txt);  // to logical vector
00020 
00021         std::cout << "We "
00022                   << (V(0) ? "do" : "do not")
00023                   << " have an environment." << std::endl;
00024         
00025     } catch(std::exception& ex) {
00026         std::cerr << "Exception caught: " << ex.what() << std::endl;
00027     } catch(...) {
00028         std::cerr << "Unknown exception caught" << std::endl;
00029     }
00030 
00031     exit(0);
00032 }
00033 
 All Classes Files Functions Variables Enumerations Enumerator Defines