Prof Brian Ripley <[EMAIL PROTECTED]> writes:
> The usual 'trick' to avoid this copy is
>
> storage.mode(x) <- "double"

Hmm, this does not appear to avoid the copy for me.  Using R 2.5.0
alpha r40916 I get:

    > x <- 1:10 * 2.3
    > names(x)=LETTERS[1:10]
    > storage.mode(x)
    [1] "double"
    > tracemem(x)
    [1] "<0x2a7f008>"
    > storage.mode(x) <- "double"
    tracemem[0x2a7f008 -> 0x1fa6df8]: 

Note that actually changing the storage results in a surprising amount
of copying:

    > storage.mode(x) <- "integer"
    tracemem[0x1fa6df8 -> 0x1fa6d60]: 
    tracemem[0x1fa6d60 -> 0x1fa6808]: as.integer.default as.integer eval eval 
storage.mode<- 
    tracemem[0x1fa6808 -> 0x2c26b18]: as.integer.default as.integer eval eval 
storage.mode<- 
    tracemem[0x2c26b18 -> 0x2c26a88]: storage.mode<- 


+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to