Re: [Rd] modifying large R objects in place

From: Byron Ellis <>
Date: Wed, 26 Sep 2007 10:52:28 -0700

For the most part, doing anything to an R object result in it's duplication. You generally have to do a lot of work to NOT copy an R object.

On 9/26/07, Petr Savicky <> wrote:
> I have a C function, which performs a transformation
> of a large integer matrix. The matrix may be of size 1.6GB,
> so I can have only one copy in RAM and have to modify it
> in place. This is possible using .Call and works fine. For
> debugging, I need two copies of a smaller matrix and modify only
> one of them. This may also be done, for example, by
> A <- some integer matrix
> B <- A + as.integer(0)
> .Call("transform", A)
> Then, B is still the original and A is the transformed one.
> Up to now, I do not have any real problem with this, but there
> are things, which could help me. Namely the following ones:
> 1. Is there a general way to duplicate an R object on the
> level of R language? I would use it instead of
> B <- A + as.integer(0)
> Looking for the keywords "duplicate" and "copy" in help pages
> and R-exts did not find what I need.
> 2. Is there a way how a C function can verify that its
> argument does not share data with other objects?
> I included a test of NAMED(A) in my C function, but I do
> not know, whether it may be used for the purpose which I need.
> I did not find a way how to generate an R object with
> NAMED equal 0. Is this possible on the level of R language?
> If yes, I will require that the argument passed to my
> function is generated in this way and the function
> will refuse to modify it if it is not so.
> The documentation suggests to call "duplicate", if the
> data are shared, but I cannot afford this due to memory.
> So, I can only stop if NAMED is not 0.
> I appreciate, if anybody could give me advice on the above things.
> Petr Savicky.
> ______________________________________________
> mailing list

Byron Ellis (
"Oook" -- The Librarian

______________________________________________ mailing list
Received on Wed 26 Sep 2007 - 17:58:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 27 Sep 2007 - 14:41:38 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.