[R] saveRDS() and readRDS() Why? [solved, kind of]

Patrick Connolly p_connolly @ending from @ling@hot@co@nz
Thu Nov 8 08:27:24 CET 2018


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.
-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.



More information about the R-help mailing list