Hi, 2011/10/6 Uwe Ligges <lig...@statistik.tu-dortmund.de>: > On 06.10.2011 14:51, Jan van der Laan wrote: >> >> An obvious reason might be that your second argument should be a pointer >> to int. >> >> As others have mentioned, you might want to have a look at Rccp and/or >> inline. The documentation is good and I find it much easier to work with. >> >> For example, your example could be written as: >> >> library(Rcpp) >> library(inline) >> >> test <- cxxfunction(signature(x = "numeric" ) , ' >> Rcpp::NumericVector v(x); >> Rcpp::NumericVector result(v.length()); >> for (int i = 0; i < v.length(); ++i) { >> result[i] = v[i] + i; >> } >> return(result); >> ', plugin = "Rcpp" ) >> > > > Oh, come on, this is now really too much of overkill.
I don't agree that it's overkill -- you get to sidestep the whole `R CMD SHLIB ...` and `dyn.load` dance this way while you experiment with C(++) code 'live" using the inline package. It's really handy. > Just make the original source > > > void test(double *b, int *l) > { > int i; > for(i=0; i < *l ; i++) b[i] += i; > } > > > which you would have know after reading the Wriiting R Extensions manual. I agree that this step is unavoidable no matter which avenue (Rcpp or otherwise) one decides to take. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.