[Rinside-commits] r209 - in pkg: . inst inst/examples/standard
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 20 05:11:29 CEST 2011
Author: edd
Date: 2011-04-20 05:11:29 +0200 (Wed, 20 Apr 2011)
New Revision: 209
Modified:
pkg/ChangeLog
pkg/inst/NEWS
pkg/inst/examples/standard/rinside_sample3.cpp
pkg/inst/examples/standard/rinside_sample5.cpp
pkg/inst/examples/standard/rinside_sample7.cpp
Log:
more small cleanups
Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog 2011-04-20 03:10:29 UTC (rev 208)
+++ pkg/ChangeLog 2011-04-20 03:11:29 UTC (rev 209)
@@ -3,11 +3,14 @@
* DESCRIPTION: Updated Description, also state current Windows
run-time issue more prominently
+ * inst/examples/standard/rinside_sample1.cpp: Minor simplification
+ * inst/examples/standard/rinside_sample2.cpp: Idem
+ * inst/examples/standard/rinside_sample3.cpp: Idem
+ * inst/examples/standard/rinside_sample5.cpp: Idem
+ * inst/examples/standard/rinside_sample7.cpp: Idem
+
2011-04-16 Dirk Eddelbuettel <edd at debian.org>
- * inst/examples/standard/rinside_sample12.cpp: Another rcpp-devel
- post leading to another simple and self-contained example
-
* inst/NEWS: Added, at long last, with backfills based on the
ChangeLog and blog postings
Modified: pkg/inst/NEWS
===================================================================
--- pkg/inst/NEWS 2011-04-20 03:10:29 UTC (rev 208)
+++ pkg/inst/NEWS 2011-04-20 03:11:29 UTC (rev 209)
@@ -1,12 +1,14 @@
0.2.4 2011-04-xx
+ o Minor code cleanups in initialization code
+
o New example embedding R inside a Qt application, along with pro file
for Qt's qmake providing a complete simple C++ GUI application
- o New rinside_sample11.cpp based on another r-help question,
- rinside_sample10.cpp based on a r-devel question
+ o New examples rinside_sample{10,11} based on questions on the
+ r-help and r-devel mailing list
- o Minor code cleanup in initialization code
+ o Some improvements and simplifications throughout examples/standard
o Added this NEWS files -- with entries below summarised from ChangeLog
and the corresponding blog posts
Modified: pkg/inst/examples/standard/rinside_sample3.cpp
===================================================================
--- pkg/inst/examples/standard/rinside_sample3.cpp 2011-04-20 03:10:29 UTC (rev 208)
+++ pkg/inst/examples/standard/rinside_sample3.cpp 2011-04-20 03:11:29 UTC (rev 209)
@@ -19,9 +19,9 @@
R.parseEvalQ(txt); // eval command, no return
// evaluate R expressions, and assign directly into Rcpp types
- Rcpp::NumericMatrix M( (SEXP) R.parseEval("swcoef <- coef(swisssum)") );
- Rcpp::StringVector cnames( (SEXP) R.parseEval("colnames(swcoef)") );
- Rcpp::StringVector rnames( (SEXP) R.parseEval("rownames(swcoef)") );
+ Rcpp::NumericMatrix M( (SEXP) R.parseEval("swcoef <- coef(swisssum)"));
+ Rcpp::StringVector cnames( (SEXP) R.parseEval("colnames(swcoef)"));
+ Rcpp::StringVector rnames( (SEXP) R.parseEval("rownames(swcoef)"));
std::cout << "\n\nAnd now from C++\n\n\t\t\t";
for (int i=0; i<cnames.size(); i++) {
Modified: pkg/inst/examples/standard/rinside_sample5.cpp
===================================================================
--- pkg/inst/examples/standard/rinside_sample5.cpp 2011-04-20 03:10:29 UTC (rev 208)
+++ pkg/inst/examples/standard/rinside_sample5.cpp 2011-04-20 03:11:29 UTC (rev 209)
@@ -2,8 +2,8 @@
//
// Another simple example inspired by an r-devel mail by Martin Becker
//
-// Copyright (C) 2009 Dirk Eddelbuettel
-// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2009 Dirk Eddelbuettel
+// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
#include <RInside.h> // for the embedded R via RInside
@@ -11,14 +11,12 @@
try {
RInside R(argc, argv); // create an embedded R instance
- SEXP ans;
std::string txt = "myenv <- new.env(hash=TRUE, size=NA)";
R.parseEvalQ(txt); // eval string quietly, no result
- txt = "as.integer(is.environment(myenv))";
- ans = R.parseEval(txt); // eval string, result in ans
- Rcpp::LogicalVector V(ans); // convert SEXP variable to vector
+ txt = "is.environment(myenv)"; // logical value assigned
+ Rcpp::LogicalVector V = R.parseEval(txt); // to logical vector
std::cout << "We "
<< (V(0) ? "do" : "do not")
Modified: pkg/inst/examples/standard/rinside_sample7.cpp
===================================================================
--- pkg/inst/examples/standard/rinside_sample7.cpp 2011-04-20 03:10:29 UTC (rev 208)
+++ pkg/inst/examples/standard/rinside_sample7.cpp 2011-04-20 03:11:29 UTC (rev 209)
@@ -2,7 +2,7 @@
//
// Showing off some of the templated as<>() conversion from Rcpp
//
-// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
#include <RInside.h> // for the embedded R via RInside
@@ -11,17 +11,14 @@
try {
RInside R(argc, argv); // create an embedded R instance
- SEXP ans;
std::string txt;
txt = "m <- 1.23";
- R.parseEval(txt, ans);
- double d1 = Rcpp::as< double >(ans);
+ double d1 = Rcpp::as< double >(R.parseEval(txt));
std::cout << "d1 " << d1 << std::endl;
txt = "M <- 1.0 * 1:6";
- R.parseEval(txt, ans);
- std::vector<double> d2 = Rcpp::as< std::vector< double > >(ans);
+ std::vector<double> d2 = Rcpp::as< std::vector< double > >(R.parseEval(txt));
std::cout << "d2[0] " << d2[0] << " d2[1] " << d2[1] << std::endl;
} catch(std::exception& ex) {
More information about the Rinside-commits
mailing list