Apologies, unserialize takes a connection, not a file, so you would need something like:

# linux (not run)
f <- file("rawData.rds", open="r")
rawData <- unserialize(f)
close(f)

The help file states that readRDS will read a file created by serialize (saveRDS is a wrapper for serialize).

It appears that the problem was "byte-shuffling at both ends when transferring data from one little-endian machine to another" and was worked around by using xdr = FALSE. So, this wouldn't necessarily work when transferring between big-endian and little-endian machines.

On 08/11/18 07:27, Patrick Connolly wrote:
Many thanks to Berwin, Eric, Robert, and Jan for their input.

I had hoped it was as simple as because I typed

saveRDS("rawData", file = "rawData.rds") on the Windows side.
but that wasn't the case.

Robert Burbridge suggested:

  windows (not run)
f <- file("rawData.rds", open="w")
serialize(rawData, f, xdr = FALSE)
close(f)

# linux
rawData <- unserialize(file = "rawData.rds")

That didn't work:
Error in unserialize(file = "rawData.rds") :
   unused argument (file = "rawData.rds")
(the argument isn't 'file')

Nor did
rawData <- unserialize("rawData.rds")
Error in unserialize("rawData.rds") :
   character vectors are no longer accepted by unserialize()

However

readRDS(file = "rawData.rds") did!

So what I needed was serialize but not unserialize.

I still don't know Why, but I know How.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to