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
ay-Ardie > Sent: Wednesday, June 19, 2013 7:15 AM > To: r-devel@r-project.org > Subject: [Rd] Calling an array in a struct in C to R > > Hi there, > > Although I'm a quite experienced R user and know my ways in C, I stumbled > upon a problem I don't know how to solve

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

2013-06-19 Thread Tee-Jay-Ardie
Hi there, Although I'm a quite experienced R user and know my ways in C, I stumbled upon a problem I don't know how to solve. Therefore, I hope someone can provide me with the information or pointers I need in order to understand the way in which the communication between R and C occurs. I have th