Re: [Rcpp-devel] Please help! A list containing dataframe

2013-09-27 Thread stat quant
This is not a Rcpp solution but be advise that as long as your function "ma" do not require values on previous lines, you might want to look at the data.table package. This package provides ultra fast operations on data.frames. Off course nothing prevents you from writing "ma" in C/C++ and to use d

Re: [Rcpp-devel] Please help! A list containing dataframe

2013-09-27 Thread Romain Francois
Hello, Storing the data frame as a vector> feels very inefficient, in essence you are copying all the data to another structure, which is not much easier to use anyway. The fun implementation feels boiler plate : int fun(MyRow row) { return boost::get<0>(row)+2*boost::get<1>(row)+3*boost::

Re: [Rcpp-devel] Please help! A list containing dataframe

2013-09-27 Thread Mark Clements
This can be done more generally. Following an earlier suggestion from Romain, we can use boost::tuple from the BH package - for a row of fixed size with general types. Then we can use a template to read in the data-frame and work with the set of rows. Variadic templates would be nice here, rat

Re: [Rcpp-devel] Struggling with cppFunction() and clusterExport()

2013-09-27 Thread Dirk Eddelbuettel
On 27 September 2013 at 11:28, Romain Francois wrote: | It might be worth handling this internally. The object could carry with | it its definition and compile itself if the pointer is the null pointer, | which is what you get apparently. | | Unless things have evolved in R, there is no way to

Re: [Rcpp-devel] Please help! A list containing dataframe

2013-09-27 Thread Romain Francois
Le 27/09/13 12:11, sky Xue a écrit : Hello, I have a list below whose elements are data frames (Please see the attached file “try.dat”). Now I want to apply a complicated function to each row of the data frame which returns a single value. For simplicity, you can assume this function is ma(x)

[Rcpp-devel] Please help! A list containing dataframe

2013-09-27 Thread sky Xue
Hello, I have a list below whose elements are data frames (Please see the attached file “try.dat”). Now I want to apply a complicated function to each row of the data frame which returns a single value. For simplicity, you can assume this function is ma(x) (x is the row of the data frame). [

Re: [Rcpp-devel] Struggling with cppFunction() and clusterExport()

2013-09-27 Thread Romain Francois
Le 27/09/13 00:20, Matteo Fasiolo a écrit : Thanks a lot for your replies, I will go for the package solution, given that I'm organizing all my code in a package in any case. Matteo That's the preferred approach. It might now however give you the flexibility of passing arbitrary functions at