[Rcpp-commits] r1895 - pkg/Rcpp/inst/doc/Rcpp-quickref

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 30 17:06:28 CEST 2010


Author: romain
Date: 2010-07-30 17:06:28 +0200 (Fri, 30 Jul 2010)
New Revision: 1895

Modified:
   pkg/Rcpp/inst/doc/Rcpp-quickref/Rcpp-quickref.Rnw
Log:
add some sugar blocks in quickrf vignette

Modified: pkg/Rcpp/inst/doc/Rcpp-quickref/Rcpp-quickref.Rnw
===================================================================
--- pkg/Rcpp/inst/doc/Rcpp-quickref/Rcpp-quickref.Rnw	2010-07-30 14:26:38 UTC (rev 1894)
+++ pkg/Rcpp/inst/doc/Rcpp-quickref/Rcpp-quickref.Rnw	2010-07-30 15:06:28 UTC (rev 1895)
@@ -92,7 +92,6 @@
 
 \paragraph{Environment}.\newline
 
-\begin{small}
 <<lang=cpp>>=
 Environment stats("package:stats") ;
 Environment env( 2 ) ; // by position
@@ -124,8 +123,44 @@
 Environment e = stats.parent() ;
 Environment e = glob.new_child() ;
 @
-\end{small}
 
+\newpage
 
+\paragraph{Rcpp sugar}.\newline
+
+<<lang=cpp>>=
+NumericVector x = NumericVector::create( 
+  -2.0, -1.0, 0.0, 1.0, 2.0 ) ;
+IntegerVector y = IntegerVector::create( 
+  -2, -1, 0, 1, 2 ) ;
+
+NumericVector xx = abs( x ) ;
+IntegerVector yy = abs( y ) ;
+
+bool b = all( x < 3.0 ).is_true()  ;
+bool b = any( y > 2 ).is_true() ;
+
+NumericVector xx = ceil( x );
+NumericVector xx = ceiling( x );
+NumericVector yy = floor( y );
+NumericVector yy = floor( y );
+
+NumericVector xx = exp( x ) ;
+NumericVector yy = exp( y ) ;
+
+NumericVector xx = head( x, 2 ) ;
+IntegerVector yy = head( y, 2 ) ;
+
+IntegerVector xx = seq_len( 10 ) ;
+IntegerVector yy = seq_along( y ) ;
+
+NumericVector xx = rep( x, 3 ) ;
+NumericVector xx = rep_len( x, 10 ) ;
+NumericVector xx = rep_each( x, 3 ) ;
+
+IntegerVector yy = rev( y ) ;
+@     
+
+
 \end{document}
 



More information about the Rcpp-commits mailing list