Re: [Rd] Get memory address of an R data frame

2020-01-10 Thread Dirk Eddelbuettel
lille stor, As a general rule, please do not cross-post. And almost certainly do not simultaneously as you did here and on https://stackoverflow.com/questions/59663174/get-memory-address-of-an-r-data-frame Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org __

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Pages, Herve
On 1/9/20 06:56, Stepan wrote: > On 09. 01. 20 15:41, lille stor wrote: > >> I believe this could be done without creating side effects (e.g. >> crash) as we are just talking about changing values. A crash would certainly be an annoying "side effect" ;-) As Stepan explained, data.frame objects

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Stepan
On 09. 01. 20 15:41, lille stor wrote: I believe this could be done without creating side effects (e.g. crash) as we are just talking about changing values. that is exactly the issue that my last two points warn about. Example: a <- mtcars .Call("my_innocent_function", a) Would you expect th

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Tomas Kalibera
On 1/9/20 1:03 PM, Ezra Tucker wrote: Hi Lille, Is it possible you're looking for tracemem() or inspect() ? Please note these functions are only for debugging. They should never be called from programs or packages. One should never try to manipulate pointers from R directly or even hold them

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Stepan
Hello Lille, raw data of a data.frame (or more precisely a list, because data.frame is just a list with "data.frame" class) is an array of R specific data structures (SEXP), so a generic C function will not be able to work with them. As a per-processing step, you may allocate an array for th

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Joris Meys
Hi Lille, To my understanding, there's no need to get the actual memory address of the R data frame, as using .Call() or .External() can be used in a "call by reference" way as well. This would be contrary to standard R behaviour, so if you use that in a package, make sure you indicate this! Ther

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Ezra Tucker
Hi Lille, Is it possible you're looking for tracemem() or inspect() ? > x <- data.frame(z = 1:10)> tracemem(x)[1] "<0x55aa743e0bc0>" > x[1] <- 2Ltracemem[0x55aa743e0bc0 -> 0x55aa778f6ad0]: tracemem[0x55aa778f6ad0 -> 0x55aa778f6868]: [<-.data.frame [<- tracemem[0x55aa778f6868 -> 0x55aa778f5b48]:

[Rd] Get memory address of an R data frame

2020-01-09 Thread lille stor
Hello, I would like for my C function to be able to manipulate some values stored in an R data frame. To achieve this, a need the (real) memory address where the R data frame stores its data (hopefully in a contiguous way). Then, from R, I call the C function and passing this memory address as