[Rinside-commits] r125 - pkg/inst/examples/standard

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 20 15:20:24 CET 2010


Author: edd
Date: 2010-03-20 15:20:24 +0100 (Sat, 20 Mar 2010)
New Revision: 125

Modified:
   pkg/inst/examples/standard/rinside_sample7.cpp
   pkg/inst/examples/standard/rinside_sample8.cpp
Log:
just added some comments to sample8 and killed on space in sample7


Modified: pkg/inst/examples/standard/rinside_sample7.cpp
===================================================================
--- pkg/inst/examples/standard/rinside_sample7.cpp	2010-03-18 18:41:31 UTC (rev 124)
+++ pkg/inst/examples/standard/rinside_sample7.cpp	2010-03-20 14:20:24 UTC (rev 125)
@@ -16,7 +16,7 @@
 
 	txt = "m <- 1.23";
         R.parseEval(txt, ans);
-	double d1 = Rcpp::as< double  >(ans);
+	double d1 = Rcpp::as< double >(ans);
 	std::cout << "d1 " << d1 << std::endl;
 
 	txt = "M <- 1.0 * 1:6";

Modified: pkg/inst/examples/standard/rinside_sample8.cpp
===================================================================
--- pkg/inst/examples/standard/rinside_sample8.cpp	2010-03-18 18:41:31 UTC (rev 124)
+++ pkg/inst/examples/standard/rinside_sample8.cpp	2010-03-20 14:20:24 UTC (rev 125)
@@ -10,14 +10,14 @@
 
     RInside R(argc, argv);              // create an embedded R instance 
     
-    R["x"] = 10 ;
+    R["x"] = 10 ;			// assignment can be done directly via []
     R["y"] = 20 ;
 
-    R.parseEvalQ("z <- x + y") ;
-    int sum = Rcpp::as<int>( R["z"] ); 
-  
+    R.parseEvalQ("z <- x + y") ;	// R statement evaluation and result 
+    int sum = Rcpp::as<int>( R["z"] ); 	// retrieval via access using [] and as() wrapper
     std::cout << "10 + 20 = " << sum << std::endl ; 
 
+    // we can also return the value directly
     sum = Rcpp::as<int>( R.parseEval("z <- x + y") ); 
     std::cout << "10 + 20 = " << sum << std::endl ; 
 



More information about the Rinside-commits mailing list