From @tep@n@@|nde|@r @end|ng |rom or@c|e@com  Thu Jan  9 15:56:45 2020
From: @tep@n@@|nde|@r @end|ng |rom or@c|e@com (Stepan)
Date: Thu, 9 Jan 2020 15:56:45 +0100
Subject: [Rd] Get memory address of an R data frame
In-Reply-To: <trinity-6d5c6b7f-e9e8-4cdf-90ca-b9ec4b97a11a-1578580918843@3c-app-mailcom-bs07>
References: <trinity-a73adb6e-7025-4545-9108-870c1a66fbfa-1578570504114@3c-app-mailcom-bs15>
 <830d3acf-aa30-5f26-408d-f35b5f0cc2d9@oracle.com>
 <trinity-6d5c6b7f-e9e8-4cdf-90ca-b9ec4b97a11a-1578580918843@3c-app-mailcom-bs07>
Message-ID: <736437f6-22b9-da92-8fb3-e931a83de39d@oracle.com>

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 that mtcars data.frame would be altered after this code 
is executed? What if some existing code relies on mtcars always 
containing the same data, which is a perfectly valid assumption given R 
specification.

If what you are trying to do is to have mutable data frame, then this 
goes against the philosophy of R. You can get mutability with 
environments and other R types that are intentionally mutable and their 
mutability is documented.

You can get data.frame mutability with the data.table package, but the 
tricks it's doing under the hood may bite back. In its source code you 
can also see how these things can be done, but unless you really need 
to, I would advise against implementing this yourself.

Best,
Stepan



[Rd] Get memory address of an R data frame
Stepan