dear all, we am trying to improve the performance of my R code, with the implentation of some function with custom C code. we found difficult to import and export/import data structure such us matrices or data.frame into the external C functions. we already tried the solution from "Writing R Extensions" form the R webpage. do you have any other solution or more advanced documentation on that point? looking forward your answer [[alternative HTML version deleted]]
Hi, On Tue, May 18, 2010 at 10:50 AM, John Lande <john.lande77 at gmail.com> wrote:> dear all, > > we am trying to improve the performance of my R code, with the implentation > of some function with custom C code. > we found difficult to import and export/import data structure such us > matrices or data.frame into the external C functions. > > we already tried the solution from "Writing R Extensions" form ?the R > webpage.Perhaps: (i) you can show us what you've tried and someone can tell help steer you in a better direction (ii) you can check out the Rcpp library. A new version was just released that you can read up on: http://romainfrancois.blog.free.fr/index.php?category/R-package/Rcpp It has lots of examples of how it should be used in its unit tests, etc. -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
John Lande <john.lande77 at gmail.com> writes:> dear all, > > we am trying to improve the performance of my R code, with the implentation > of some function with custom C code. > we found difficult to import and export/import data structure such us > matrices or data.frame into the external C functions.Please give a *very simple* example of what you're trying and failing to do. Use the .C() interface, forget about the .Call interface. Then it is not that hard. Start with the convolve example on p.69 and 70 of Writing R Extensions. Get that working and then turn it into your problem. Forget about lists and data frames: everything is going to be a simple vector. That includes arrays and matrices: you can pass them in, but C will know nothing about their dimensions until you tell it. Of course, you can pass the dimension vectors in as a separate vector. So, if you use arrays, you need to understand the order in which R stores the elements of the array. If your problem cannot be solved with the .C interface then you should consider whether it is worthwhile to proceed as the .Call interface repays those who use it frequently but has a considerably steeper learning (and forgetting) curve. Dan> > we already tried the solution from "Writing R Extensions" form the R > webpage. > > do you have any other solution or more advanced documentation on that point? > > looking forward your answer > > [[alternative HTML version deleted]]