[Rd] corruption of data with serialize(ascii=TRUE)

From: Roger D. Peng <rpeng_at_jhsph.edu>
Date: Wed 08 Feb 2006 - 22:45:54 GMT


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/

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu Feb 09 11:27:11 2006

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:40 GMT