saveRDS() and readRDS() Why? [solved, kind of]
Patrick Connolly
on Thu, 8 Nov 2018 20:27:24 +1300 writes:
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.
Hmm.. and nobody has been able to reproduce your problem, right?
IIUC, currently you are suggesting that [on Windows], if you do
saveRDS(rawdata, file="rawdata.rds")
the resulting file is does not work with readRDS() on Linux.
What again are your R versions on the two platforms?
Could you dput() -- provide a (short if possible) version of rawdata where
that problem occurs ?
Best,
Martin
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
___ Patrick Connolly
{~._.~} Great minds discuss ideas
_( Y )_ Average minds discuss events
(:_~*~_:) Small minds discuss people
(_)-(_) ..... Eleanor Roosevelt
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
______________________________________________ R-help at 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.