[Rcpp-devel] how to use functions from other packages
Thanks Dirk. I was hoping for an example of the use of R functions in Rcpp and did take a look at your Journal of Statistical software paper but was hoping for more than is there on this issue. Maybe someone can post a full example. On a different issue, I tried the inline example in your JSS paper on my Windows 7 machine after loading the inline library src = ' Rcpp::NumericVector xa(a); Rcpp::NumericVector xb(b); int n_xa = xa.size(), n_xb = xb.size(); Rcpp::NumericVector xab(n_xa + n_xb - 1); for (int i = 0; i < n_xa; i++) for (int j = 0; j < n_xb; j++) xab[i + j] += xa[i] * xb[j]; return xab; ' fun <- cxxfunction(signature(a = "numeric", b = "numeric"), src, plugin = "Rcpp") R> fun(1:3, 1:4) and got the following error message Error in system(cmd, intern = !verbose) : 'C:/Program' not found What could the problem be? Thanks in advance on both scores. Siddhartha.
On 4/23/2011 9:25 PM, Dirk Eddelbuettel wrote:
On 23 April 2011 at 21:05, Dirk Eddelbuettel wrote:
|
| On 23 April 2011 at 20:36, Siddhartha Chib wrote:
| | This is likely to be too simple a question perhaps. How does one use specific
| | functions from other packages when working with Rcpp? For that matter, is it
| | possible to use R functions such as optim in Rcpp?
|
| Yes, sure. I don't think we have a great example though.
[...]
| A concise example would be good. Maybe another list member has something?
PS This may be obvious too, but let's just state it plainly to be sure: in
iterative optimisation, if you repeatedly go back between R and C++ you
are likely to give up a bunch of the speed gain Rcpp can otherwise offer.
There are other tricks one can use to access the _C_ part of certain R
functions. Frequent list contributor Davor had done some nice work getting
at the inner (C language) part of loess(); that is now also in a CRAN
package 'rgam' which uses Rcpp and RcppArmdillo:
http://cran.r-project.org/web/packages/rgam/index.html
Hope this helps, Dirk
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110424/45dfa1e6/attachment.htm>