Re: [R] saveRDS() and readRDS() Why? [solved, pretty much anyway)

2018-11-13 Thread William Dunlap via R-help
Perhaps you got bitten by Dolphin's non-modal dialogs, as described in https://userbase.kde.org/Dolphin/File_Management: Non Modal Dialogs When Moving, Copying or Deleting files/directories the dialog disappears even when the operation has not yet completed. A progress bar then appears in the

Re: [R] saveRDS() and readRDS() Why? [solved, pretty much anyway)

2018-11-13 Thread p_connolly
This is getting more strange. I normally copy from the shared folder to the appropriate directory using Dolphin, the KDE file manager. If instead I use the standard bash cp command, no corruption happens -- at least with the limited testing I have done. There also seems to be no problem

Re: [R] saveRDS() and readRDS() Why? [solved, pretty much anyway)

2018-11-13 Thread William Dunlap via R-help
It seems like copying the files corrupted them. How did you copy them (with R or cp or copy or ftp, etc.)? I don't see how this has anything to do with R. Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Nov 12, 2018 at 7:10 PM, p_connolly wrote: > On 2018-11-13 12:55, William Dunlap

Re: [R] saveRDS() and readRDS() Why? [solved, pretty much anyway)

2018-11-12 Thread p_connolly
On 2018-11-13 12:55, William Dunlap wrote: You wrote: ## On Windows 3.4.2 x <- airquality saveRDS(x, file = "x.rds") saveRDS(x, file = "y.rds") Files x.rds and y.rds are identical in size but utterly different in content. Wow! Can you show us the results of x <- datasets::airquality

Re: [R] saveRDS() and readRDS() Why? [solved, pretty much anyway)

2018-11-12 Thread William Dunlap via R-help
You wrote: ## On Windows 3.4.2 > x <- airquality > saveRDS(x, file = "x.rds") > saveRDS(x, file = "y.rds") > Files x.rds and y.rds are identical in size but utterly different in content. Wow! Can you show us the results of x <- datasets::airquality saveRDS(x, file="x.rds")

Re: [R] saveRDS() and readRDS() Why? [solved, pretty much anyway)

2018-11-12 Thread p_connolly
On 2018-11-12 22:49, peter dalgaard wrote: Er, where, what, how? I can't reproduce that, at least not on 3.5.1 on MacOS: x <- airquality saveRDS(x, file = "x.rds") x <- NULL x <- readRDS(file = "x.rds") x Ozone Solar.R Wind Temp Month Day 1 41 190 7.4 67 5 1 2 36

Re: [R] saveRDS() and readRDS() Why? [solved, pretty much anyway)

2018-11-12 Thread Patrick Connolly
The solution was very simple. Don't use the same name for the rds file as used for the R object, viz a vie: saveRDS(x, file = "x.rds") and x <- readRDS(file = "x.rds") will not work; however saveRDS(x, file = "y.rds") and x <- readRDS(file = "y.rds") will work. An undocumented feature?

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

2018-11-10 Thread Patrick Connolly
On Thu, 08-Nov-2018 at 11:06AM +0100, Martin Maechler wrote: |> > Patrick Connolly |> > on Thu, 8 Nov 2018 20:27:24 +1300 writes: [...] |> > |> > I still don't know Why, but I know How. |> |> Hmm.. and nobody has been able to reproduce your problem, right? |> |> IIUC, currently

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

2018-11-08 Thread Robert David Burbidge via R-help
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

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

2018-11-08 Thread Martin Maechler
> 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. > >

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

2018-11-07 Thread Patrick Connolly
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")

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Robert David Burbidge via R-help
Patrick, I cannot reproduce this behaviour. I'm using: Windows 8.1; R 3.5.1; RStudio 1.1.463 running in a VirtualBox on Ubuntu 18.04 with R 3.4.4; RStudio 1.1.456 The file size of rawData.rds is always 88 bytes in my example and od gives the same results on Windows and Linux. I am using a

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Jan van der Laan
Are you sure you didn't do saveRDS("rawData", file = "rawData.rds") instead of saveRDS(rawData, file = "rawData.rds") ? This would explain the result you have under linux. In principle saveRDS and readRDS can be used to copy objects between R-sessions without loosing information. What

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Robert David Burbidge via R-help
If the file sizes are the same, then presumably both contain the binary data. From the serialize function help: "As almost all systems in current use are little-endian, xdr = FALSE can be used to avoid byte-shuffling at both ends when transferring data from one little-endian machine to

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Eric Berger
Your understanding is correct. It works fine for me. On Wed, Nov 7, 2018 at 10:48 AM Patrick Connolly wrote: > On Wed, 07-Nov-2018 at 08:27AM +, Robert David Burbidge wrote: > > |> Hi Patrick, > |> > |> From the help: "save writes a single line header (typically > |> "RDXs\n") before the

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Patrick Connolly
On Wed, 07-Nov-2018 at 08:27AM +, Robert David Burbidge wrote: |> Hi Patrick, |> |> From the help: "save writes a single line header (typically |> "RDXs\n") before the serialization of a single object". |> |> If the file sizes are the same (see Eric's message), then the |> problem may be

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Patrick Connolly
They're both about 3kb. On 7/11/18 9:13 PM, Eric Berger wrote: > What do you see at the OS level? > i.e. on windows > DIR rawData.rds > on linux > ls -l rawData.rds > compare the file sizes on both. > > > On Wed, Nov 7, 2018 at 9:56 AM Patrick Connolly > mailto:p_conno...@slingshot.co.nz>>

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Robert David Burbidge via R-help
Hi Patrick, From the help: "save writes a single line header (typically "RDXs\n") before the serialization of a single object". If the file sizes are the same (see Eric's message), then the problem may be due to different line terminators. Try serialize and unserialize for low-level control

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Eric Berger
What do you see at the OS level? i.e. on windows DIR rawData.rds on linux ls -l rawData.rds compare the file sizes on both. On Wed, Nov 7, 2018 at 9:56 AM Patrick Connolly wrote: > From a Windows R session, I do > > > object.size(rawData) > 31736 bytes # from scraping a non-reproducible web

[R] saveRDS() and readRDS() Why?

2018-11-06 Thread Patrick Connolly
>From a Windows R session, I do > object.size(rawData) 31736 bytes # from scraping a non-reproducible web address. > saveRDS(rawData, file = "rawData.rds") Then copy to a Linux session > rawData <- readRDS(file = "rawData.rds") > rawData [1] "rawData" > object.size(rawData) 112 bytes >