[Rd] corruption of data with serialize(ascii=TRUE)
Roger D. Peng
rpeng at jhsph.edu
Wed Feb 8 23:45:54 CET 2006
I noticed the following peculiarity with `serialize()' when `ascii = TRUE' is
used. In today's (svn r37299) R-devel, I get
> set.seed(10)
> x <- rnorm(10)
>
> a <- serialize(x, con = NULL, ascii = TRUE)
> b <- unserialize(a)
>
> identical(x, b) ## FALSE
[1] FALSE
> x - b
[1] -3.469447e-18 2.775558e-17 -4.440892e-16 0.000000e+00 5.551115e-17
[6] -5.551115e-17 -4.440892e-16 0.000000e+00 2.220446e-16 -5.551115e-17
I expected `x' and `b' to be identical, which is what I get when `ascii = FALSE':
> a <- serialize(x, con = NULL, ascii = FALSE)
> b <- unserialize(a)
>
> identical(x, b) ## TRUE
[1] TRUE
The same phenomenon occurs with `.saveRDS(ascii = TRUE)',
> .saveRDS(x, file = "asdf", ascii = TRUE)
> d <- .readRDS("asdf")
>
> identical(x, d) ## FALSE
[1] FALSE
>
Has anyone noticed this before? I didn't see anything in the docs for
`serialize()' that would indicate this behavior should be expected.
I'm on Linux Fedora Core 4.
-roger
--
Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/
More information about the R-devel
mailing list