[Rd] modifying large R objects in place
Byron Ellis
byron.ellis at gmail.com
Wed Sep 26 19:52:28 CEST 2007
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 <savicky at cs.cas.cz> 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.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Byron Ellis (byron.ellis at gmail.com)
"Oook" -- The Librarian
More information about the R-devel
mailing list