[Rcpp-devel] Bug report: need to wrap return of sugar functions
Dirk Eddelbuettel
edd at debian.org
Tue Aug 16 04:31:30 CEST 2011
On 16 August 2011 at 11:11, Darren Cook wrote:
| On 2011-08-16 08:34, Wray, Christopher wrote:
| > =============
| > x=matrix(1:12,4,3);
| > print(ifelse(x<5,x*x,x))
| >
| > src2='
| > using namespace Rcpp;
| > NumericMatrix x(x_);
| > NumericVector y=ifelse(x<5,x*x,x);
| > y.attr("dim")=Dimension(x.nrow(),x.ncol());
| > return y;
| > '
| > fun=cxxfunction(signature(x_ ="integer"),src2,plugin="Rcpp")
| > print(fun(x))
| >
| > ===========
| > does this do it for you
|
| Hello Christopher,
| Thanks for the suggestion. It works perfectly (I suspect some template
| magic could make this assignment automatic).
Patches are always welcome :-) We can offer rewards as glorious as an entry
in the inst/THANKS file installed with Rcpp.
Dirk
--
Two new Rcpp master classes for R and C++ integration scheduled for
New York (Sep 24) and San Francisco (Oct 8), more details are at
http://dirk.eddelbuettel.com/blog/2011/08/04#rcpp_classes_2011-09_and_2011-10
http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php
More information about the Rcpp-devel
mailing list