Re: [Rd] Calling an array in a struct in C to R

2013-06-21 Thread Dirk Eddelbuettel
On 20 June 2013 at 05:44, Tee-Jay-Ardie wrote: | I guess I should start reading up on .Call. If you look back into the R-devel archives as of a few months ago, a long thread there came (fairly strongly and unanimously) to the exact conclusion. With that allow me to make the case a little more s

Re: [Rd] Calling an array in a struct in C to R

2013-06-20 Thread Tee-Jay-Ardie
Terry Therneau-2 wrote > Another solution is the one used for a long time in the rpart code. > The R code called "rpart1", which does the work, keeps a static pointer to > the object, > does NOT > release it's memory, and returned the size of the object. > > Then the R code allocates appropriate

Re: [Rd] Calling an array in a struct in C to R

2013-06-20 Thread Romain Francois
Hello, I would use external pointers for something like this. If c++ is an option, you can take advantage of Rcpp classes to deal with external pointers. Put the following in a .cpp and sourceCpp() it. #include using namespace Rcpp ; class Array { public: Array( ) : size(10), used(0){

Re: [Rd] Calling an array in a struct in C to R

2013-06-20 Thread Terry Therneau
Another solution is the one used for a long time in the rpart code. The R code called "rpart1", which does the work, keeps a static pointer to the object, does NOT release it's memory, and returned the size of the object. Then the R code allocates appropriate vectors and called "rpart2", which f

Re: [Rd] Calling an array in a struct in C to R

2013-06-19 Thread William Dunlap
> should I rewrite my C code using Call in R? Yes, rewrite it to use the .Call() interface. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On > Behalf > Of Tee-Jay-Ardie > Sent: We