From jor|@mey@ @end|ng |rom gm@||@com  Thu Jan  9 13:58:19 2020
From: jor|@mey@ @end|ng |rom gm@||@com (Joris Meys)
Date: Thu, 9 Jan 2020 13:58:19 +0100
Subject: [Rd] Get memory address of an R data frame
In-Reply-To: <trinity-a73adb6e-7025-4545-9108-870c1a66fbfa-1578570504114@3c-app-mailcom-bs15>
References: <trinity-a73adb6e-7025-4545-9108-870c1a66fbfa-1578570504114@3c-app-mailcom-bs15>
Message-ID: <CAO1zAVabrcDK1S1Fr_e55NX8EkkV3a+EmD+457b-r7e+8Ad9TQ@mail.gmail.com>

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!

There's a detailed explanation on how to deal with R objects in C code in
the manual "Writing R extensions" here :

https://cran.r-project.org/doc/manuals/R-exts.html#Handling-R-objects-in-C

Especially check the section "Named objects and copying", which explains in
more detail how to control the standard R behaviour. Also keep in mind that
data frames are list-like structures, which are handled differently from
atomic vectors.

Hope this helps.
Kind regards
Joris

On Thu, Jan 9, 2020 at 12:48 PM lille stor <lille.stor at gmx.com> wrote:

> 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 a parameter.
>
> The question: how can we get the memory address of the R data frame?
>
> Thank you!
>
> L.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


-- 
Joris Meys
Statistical consultant

Department of Data Analysis and Mathematical Modelling
Ghent University
Coupure Links 653, B-9000 Gent (Belgium)
<https://maps.google.com/?q=Coupure+links+653,%C2%A0B-9000+Gent,%C2%A0Belgium&entry=gmail&source=g>
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]



[Rd] Get memory address of an R data frame
Joris Meys