Re: [Rcpp-devel] Rccp code with vector and matrix inputs and matrix output

2014-03-28 Thread Hadley Wickham
I'd recommend: a) using cppFunction instead of the older cxxfunction b) creating an example that anyone can copy and paste out of their email client and into R. You are more likely to get helpful responses if you reduce the burden on the potential helpers as much as possible Hadley On Fri, Mar

Re: [Rcpp-devel] Rccp code with vector and matrix inputs and matrix output

2014-03-28 Thread Dirk Eddelbuettel
On 28 March 2014 at 13:51, Petre Caraiani wrote: | Thank you for your quick reply! | I corrected the issue mentioned by you, but I get the same error. | It must be a beginner's issue. | | The data is quite big, but this kind of output could be produced with any | random data, I guess. | | Namely

Re: [Rcpp-devel] Rccp code with vector and matrix inputs and matrix output

2014-03-28 Thread Petre Caraiani
Thank you for your quick reply! I corrected the issue mentioned by you, but I get the same error. It must be a beginner's issue. The data is quite big, but this kind of output could be produced with any random data, I guess. Namely, using the Rcpp, I get Am as: [,1] [,2] [,3] [,4] [,5] [,6

Re: [Rcpp-devel] Rccp code with vector and matrix inputs and matrix output

2014-03-28 Thread Gregor Kastner
Hi Petre, > The following code works well in R: > attach(dataqtr) Not for me, because my vanilla copy of R doesn't know about dataqtr. It's helpful to provide reproducible examples. > However I am not able to reproduce it using the following Rccp code: > > a<- dataqtr[,LTG] > b<- dataqtr[,mean

Re: [Rcpp-devel] Rccp code with vector and matrix inputs and matrix output

2014-03-28 Thread Dirk Eddelbuettel
On 28 March 2014 at 10:30, Petre Caraiani wrote: | Hello, | The following code works well in R: | attach(dataqtr) | | dataqtr <- data.table(dataqtr) | setkeyv(dataqtr,c("gvkey","qtr")) | | vec_growth <- data.frame(0,0,0,0,0,0,0,0,0,0,0,0,0) | vec_eps    <- data.frame(0,0,0,0,0,0,0,0,0,0,0,0,0) |

[Rcpp-devel] Rccp code with vector and matrix inputs and matrix output

2014-03-28 Thread Petre Caraiani
Hello, The following code works well in R: attach(dataqtr) dataqtr <- data.table(dataqtr) setkeyv(dataqtr,c("gvkey","qtr")) vec_growth <- data.frame(0,0,0,0,0,0,0,0,0,0,0,0,0) vec_eps<- data.frame(0,0,0,0,0,0,0,0,0,0,0,0,0) T <- 15 for (i in 1:nrow(dataqtr)) { vec_growth[i,] <- ( dataqtr[