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 bottom right of the screen, this then disappears also, if you want
see the progress you need to click a small (i) information icon in the
system tray.


Warning
New users who are not used to this way of working (and even experienced
users) can get caught out by this, if you are Moving, Copying or Deleting
large directories then you need to use the icon to monitor the progress of
your operation. If you don't then any subsequent actions you do, may well
use an incomplete file structure resulting in corrupted files. You have
been warned!

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Nov 13, 2018 at 2:10 PM, p_connolly 
wrote:

> 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 copying from Linux to Windows.  I
> installed R-3.5.1 for Windows just to eliminate that possible issue.
>
> However, R has *something* to do with it because it was used to make the
> .rds file.  Just how the relationship between the name of the R object and
> the name of the .rds file comes into it, I can't imagine.
>
> Thanks for the suggestion William.
>
>
> On 2018-11-14 06:26, William Dunlap wrote:
>
>> 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 [1]
>> On Mon, Nov 12, 2018 at 7:10 PM, p_connolly
>>  wrote:
>>
> [...]
>
>

[[alternative HTML version deleted]]

__
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.


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 copying from Linux to 
Windows.  I installed R-3.5.1 for Windows just to eliminate that 
possible issue.


However, R has *something* to do with it because it was used to make the 
.rds file.  Just how the relationship between the name of the R object 
and the name of the .rds file comes into it, I can't imagine.


Thanks for the suggestion William.


On 2018-11-14 06:26, William Dunlap wrote:

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 [1]
On Mon, Nov 12, 2018 at 7:10 PM, p_connolly
 wrote:

[...]

__
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.


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 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
>>   saveRDS(x, file="x.rds")
>>   saveRDS(x, file="y.rds")
>>   tools::md5sum(c("x.rds", "y.rds"))
>>   dput(readBin("x.rds", what="raw", n=file.size("x.rds")))
>>   dput(readBin("y.rds", what="raw", n=file.size("y.rds")))
>>
>> (Copy and paste, as text, from the R session, so we can see the input
>> and the output in context.
>>
>
> If I do that on Linux or Windows, I get identical files.
>
> If I copy x.rds and y.rds from Windows to Linux (which is what I wish to
> be able to do) using a shared folder between the Windows VirtualBox host to
> the Linux guest, I  get this:
>
>
> x <- readRDS(file =  "x.rds")
>>
> Error in readRDS(file = "x.rds") : error reading from connection
>
>> x <- readRDS(file =  "y.rds")
>>   tools::md5sum(c("x.rds", "y.rds"))
>>
>  x.rds  y.rds
> "5fef054848f39b4be02b7c54f1c71a20" "978a64d1dd342d16a381c9ca728d3665"
>
>>   dput(readBin("x.rds", what="raw", n=file.size("x.rds")))
>>
> as.raw(c(0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 

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
  saveRDS(x, file="x.rds")
  saveRDS(x, file="y.rds")
  tools::md5sum(c("x.rds", "y.rds"))
  dput(readBin("x.rds", what="raw", n=file.size("x.rds")))
  dput(readBin("y.rds", what="raw", n=file.size("y.rds")))

(Copy and paste, as text, from the R session, so we can see the input
and the output in context.


If I do that on Linux or Windows, I get identical files.

If I copy x.rds and y.rds from Windows to Linux (which is what I wish to 
be able to do) using a shared folder between the Windows VirtualBox host 
to the Linux guest, I  get this:




x <- readRDS(file =  "x.rds")

Error in readRDS(file = "x.rds") : error reading from connection

x <- readRDS(file =  "y.rds")
  tools::md5sum(c("x.rds", "y.rds"))

 x.rds  y.rds
"5fef054848f39b4be02b7c54f1c71a20" "978a64d1dd342d16a381c9ca728d3665"

  dput(readBin("x.rds", what="raw", n=file.size("x.rds")))

as.raw(c(0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,

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")
  saveRDS(x, file="y.rds")
  tools::md5sum(c("x.rds", "y.rds"))
  dput(readBin("x.rds", what="raw", n=file.size("x.rds")))
  dput(readBin("y.rds", what="raw", n=file.size("y.rds")))

(Copy and paste, as text, from the R session, so we can see the input and
the output in context.





Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Nov 12, 2018 at 12:42 PM, p_connolly 
wrote:

> 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 118  8.0   72 5   2
>> 3  12 149 12.6   74 5   3
>> ...
>>
>> Looks fine to me.
>>
>>
> It seems to work fine using the same installation to read as used for the
> save.
> But it's a different story if the save was done on a Windows installation
> and read on a Linux installation.
>
> ## 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.
>
> ## On Linux 3.5.1
>
> x <- readRDS(file =  "x.rds")
>>
> Error in readRDS(file = "x.rds") : error reading from connection
>
>> x <- readRDS(file =  "y.rds")
>> head(x)
>>
>   Ozone Solar.R Wind Temp Month Day
> 141 190  7.4   67 5   1
> 236 118  8.0   72 5   2
> 312 149 12.6   74 5   3
> 418 313 11.5   62 5   4
> 5NA  NA 14.3   56 5   5
> 628  NA 14.9   66 5   6
>
> It might just be the age of the Windows installation.  I don't have much
> use for Windows, so I haven't had much inclination to install a newer
> version.
>
> YMMV
>
>
>
> ?
>> -pd
>>
>>
>> On 12 Nov 2018, at 08:28 , Patrick Connolly 
>>> wrote:
>>>
>>> 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?
>>>
>>> Thanks to all who contributed.
>>>
>>
>> --
>> Peter Dalgaard, Professor,
>> Center for Statistics, Copenhagen Business School
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> Phone: (+45)38153501
>> Office: A 4.23
>> Email: pd@cbs.dk  Priv: pda...@gmail.com
>>
>
> __
> 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/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
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.


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 118  8.0   72 5   2
3  12 149 12.6   74 5   3
...

Looks fine to me.



It seems to work fine using the same installation to read as used for 
the save.
But it's a different story if the save was done on a Windows 
installation and read on a Linux installation.


## 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.


## On Linux 3.5.1


x <- readRDS(file =  "x.rds")

Error in readRDS(file = "x.rds") : error reading from connection

x <- readRDS(file =  "y.rds")
head(x)

  Ozone Solar.R Wind Temp Month Day
141 190  7.4   67 5   1
236 118  8.0   72 5   2
312 149 12.6   74 5   3
418 313 11.5   62 5   4
5NA  NA 14.3   56 5   5
628  NA 14.9   66 5   6

It might just be the age of the Windows installation.  I don't have much 
use for Windows, so I haven't had much inclination to install a newer 
version.


YMMV




?
-pd


On 12 Nov 2018, at 08:28 , Patrick Connolly 
 wrote:


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?

Thanks to all who contributed.


--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com


__
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.


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?

Thanks to all who contributed.



On Sat, 10-Nov-2018 at 08:48PM +1300, Patrick Connolly wrote:

|> 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 you are suggesting that [on Windows], if you do
|> |> 
|> |>   saveRDS(rawdata, file="rawdata.rds")
|> |> 
|> |> the resulting file is does not work withreadRDS()  on Linux.
|> |> What again are your R versions on the two platforms?
|> 
|> 
|> It's an old version on Windows.  I haven't used Windows R since then.
|> 
|> major  3  
|> minor  2.4
|> year   2016   
|> month  03 
|> day16 
|> 
|> 
|> I've tried R-3.5.0 and R-3.5.1 Linux versions.  The problem might be
|> entirely because of the ancient Windows version. 
|> 
|> 
|> |> 
|> |> Could you  dput() -- provide a (short if possible) version of rawdata 
where
|> |> that problem occurs ?
|> 
|> I can't make a smaller version of rawdata which comes from scraping a
|> non-public web address, but next week when I'm back where those
|> machines are, I'll try it with a small data frame which is
|> reproducible.
|> 
|> 
|> 
|> |> 
|> |> Best,
|> |> Martin
|> |> 
|> |> 
|> |> > 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
|> |> >___Patrick Connolly   
|> |> >  {~._.~}   Great minds discuss ideas
|> |> >  _( Y )_ Average minds discuss events 
|> |> > (:_~*~_:)  Small minds discuss people  
|> |> >  (_)-(_)  . Eleanor Roosevelt
|> |> >   
|> |> > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> |> > 
|> |> > __
|> |> > 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.
|> 
|> -- 
|> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
|>___Patrick Connolly   
|>  {~._.~}   Great minds discuss ideas
|>  _( Y )_  Average minds discuss events 
|> (:_~*~_:)  Small minds discuss people  
|>  (_)-(_)   . Eleanor Roosevelt
|>
|> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> 
|> __
|> 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.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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.


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 you are suggesting that [on Windows], if you do
|> 
|>   saveRDS(rawdata, file="rawdata.rds")
|> 
|> the resulting file is does not work withreadRDS()  on Linux.
|> What again are your R versions on the two platforms?


It's an old version on Windows.  I haven't used Windows R since then.

major  3  
minor  2.4
year   2016   
month  03 
day16 


I've tried R-3.5.0 and R-3.5.1 Linux versions.  The problem might be
entirely because of the ancient Windows version. 


|> 
|> Could you  dput() -- provide a (short if possible) version of rawdata where
|> that problem occurs ?

I can't make a smaller version of rawdata which comes from scraping a
non-public web address, but next week when I'm back where those
machines are, I'll try it with a small data frame which is
reproducible.



|> 
|> Best,
|> Martin
|> 
|> 
|> > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
|> >___Patrick Connolly   
|> >  {~._.~}   Great minds discuss ideas
|> >  _( Y )_Average minds discuss events 
|> > (:_~*~_:)  Small minds discuss people  
|> >  (_)-(_) . Eleanor Roosevelt
|> >  
|> > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> > 
|> > __
|> > 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.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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.


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 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.


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.
> 
> 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 withreadRDS()  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@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.

__
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.


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")
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
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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.


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 VirtualBox shared folder to transfer from Windows to Linux.

Could you provide details of your machines?

Rgds,

Robert


On 07/11/18 07:56, Patrick Connolly wrote:

 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

rawData

[1] "rawData" # only the name and something to make up 112 bytes
Have I misunderstood the syntax?

It's an old version on Windows.  I haven't used Windows R since then.

major  3
minor  2.4
year   2016
month  03
day16


I've tried R-3.5.0 and R-3.5.1 Linux versions.

In case it's material ...

I couldn't get the scraping to work on either of the R installations
but Windows users told me it worked for them.  So I thought I'd get
the R object and use it.  I could understand accessing the web address
could have different permissions for different OSes, but should that
affect the R objects?

TIA



__
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.


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 does readRDS return on windows with the same file?

What type of object is rawData? Do str(rawData). Some objects created by 
packages cannot be serialized, e.g. objects that point to memory 
allocated by a package. The pointer is then serialized not the memory 
pointed to.


Also, if the object is generated by a package, you might need to load 
the package to get the printing etc. of the object right.


HTH,

Jan







On 07-11-18 09:45, 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 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 of saving/reading objects.

I'll have to find out what 'serialize' means.

On Windows, it's a huge table, looks like it's all hexadecimal.

On Linux, it's just the text string 'rawData' -- a lot more than line
terminators.

Have I misunderstood what the idea is?  I thought I'd get an identical
object, irrespective of how different the OS stores and zips it.



|>
|> Rgds,
|>
|> Robert
|>
|>
|> On 07/11/18 08:13, 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 
|> >wrote:
|> >
|> >> 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
|> >>>rawData
|> >>[1] "rawData" # only the name and something to make up 112 bytes
|> >>Have I misunderstood the syntax?
|> >>
|> >>It's an old version on Windows.  I haven't used Windows R since then.
|> >>
|> >>major  3
|> >>minor  2.4
|> >>year   2016
|> >>month  03
|> >>day16
|> >>
|> >>
|> >>I've tried R-3.5.0 and R-3.5.1 Linux versions.
|> >>
|> >>In case it's material ...
|> >>
|> >>I couldn't get the scraping to work on either of the R installations
|> >>but Windows users told me it worked for them.  So I thought I'd get
|> >>the R object and use it.  I could understand accessing the web address
|> >>could have different permissions for different OSes, but should that
|> >>affect the R objects?
|> >>
|> >>TIA
|> >>
|> >>--
|> >>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> >>___Patrick Connolly
|> >>  {~._.~}   Great minds discuss ideas
|> >>  _( Y )_ Average minds discuss events
|> >>(:_~*~_:)  Small minds discuss people
|> >>  (_)-(_)  . Eleanor Roosevelt
|> >>
|> >>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> >>
|> >>__
|> >>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.
|> >>
|> >  [[alternative HTML version deleted]]
|> >
|> >__
|> >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.



__
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.


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 another (or between processes on the same machine). Depending on the system, this can 
speed up serialization and unserialization by a factor of up to 3x."

So you could try:

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

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

HTH

On 07/11/18 08:45, 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 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 of saving/reading objects.

I'll have to find out what 'serialize' means.

On Windows, it's a huge table, looks like it's all hexadecimal.

On Linux, it's just the text string 'rawData' -- a lot more than line
terminators.

Have I misunderstood what the idea is?  I thought I'd get an identical
object, irrespective of how different the OS stores and zips it.



|>
|> Rgds,
|>
|> Robert
|>
|>
|> On 07/11/18 08:13, 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 
|> >wrote:
|> >
|> >> 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
|> >>>rawData
|> >>[1] "rawData" # only the name and something to make up 112 bytes
|> >>Have I misunderstood the syntax?
|> >>
|> >>It's an old version on Windows.  I haven't used Windows R since then.
|> >>
|> >>major  3
|> >>minor  2.4
|> >>year   2016
|> >>month  03
|> >>day16
|> >>
|> >>
|> >>I've tried R-3.5.0 and R-3.5.1 Linux versions.
|> >>
|> >>In case it's material ...
|> >>
|> >>I couldn't get the scraping to work on either of the R installations
|> >>but Windows users told me it worked for them.  So I thought I'd get
|> >>the R object and use it.  I could understand accessing the web address
|> >>could have different permissions for different OSes, but should that
|> >>affect the R objects?
|> >>
|> >>TIA
|> >>
|> >>-



__
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.


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 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 of saving/reading objects.
>
> I'll have to find out what 'serialize' means.
>
> On Windows, it's a huge table, looks like it's all hexadecimal.
>
> On Linux, it's just the text string 'rawData' -- a lot more than line
> terminators.
>
> Have I misunderstood what the idea is?  I thought I'd get an identical
> object, irrespective of how different the OS stores and zips it.
>
>
>
> |>
> |> Rgds,
> |>
> |> Robert
> |>
> |>
> |> On 07/11/18 08:13, 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 <
> p_conno...@slingshot.co.nz>
> |> >wrote:
> |> >
> |> >> 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
> |> >>>rawData
> |> >>[1] "rawData" # only the name and something to make up 112 bytes
> |> >>Have I misunderstood the syntax?
> |> >>
> |> >>It's an old version on Windows.  I haven't used Windows R since then.
> |> >>
> |> >>major  3
> |> >>minor  2.4
> |> >>year   2016
> |> >>month  03
> |> >>day16
> |> >>
> |> >>
> |> >>I've tried R-3.5.0 and R-3.5.1 Linux versions.
> |> >>
> |> >>In case it's material ...
> |> >>
> |> >>I couldn't get the scraping to work on either of the R installations
> |> >>but Windows users told me it worked for them.  So I thought I'd get
> |> >>the R object and use it.  I could understand accessing the web address
> |> >>could have different permissions for different OSes, but should that
> |> >>affect the R objects?
> |> >>
> |> >>TIA
> |> >>
> |> >>--
> |>
> >>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
> |> >>___Patrick Connolly
> |> >>  {~._.~}   Great minds discuss ideas
> |> >>  _( Y )_ Average minds discuss events
> |> >>(:_~*~_:)  Small minds discuss people
> |> >>  (_)-(_)  . Eleanor Roosevelt
> |> >>
> |>
> >>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
> |> >>
> |> >>__
> |> >>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.
> |> >>
> |> >[[alternative HTML version deleted]]
> |> >
> |> >__
> |> >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.
>
> --
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>___Patrick Connolly
>  {~._.~}   Great minds discuss ideas
>  _( Y )_ Average minds discuss events
> (:_~*~_:)  Small minds discuss people
>  (_)-(_)  . Eleanor Roosevelt
>
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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.


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 due to different line terminators. Try serialize and
|> unserialize for low-level control of saving/reading objects.

I'll have to find out what 'serialize' means.

On Windows, it's a huge table, looks like it's all hexadecimal.  

On Linux, it's just the text string 'rawData' -- a lot more than line
terminators.

Have I misunderstood what the idea is?  I thought I'd get an identical
object, irrespective of how different the OS stores and zips it.



|> 
|> Rgds,
|> 
|> Robert
|> 
|> 
|> On 07/11/18 08:13, 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 
|> >wrote:
|> >
|> >> 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
|> >>>rawData
|> >>[1] "rawData" # only the name and something to make up 112 bytes
|> >>Have I misunderstood the syntax?
|> >>
|> >>It's an old version on Windows.  I haven't used Windows R since then.
|> >>
|> >>major  3
|> >>minor  2.4
|> >>year   2016
|> >>month  03
|> >>day16
|> >>
|> >>
|> >>I've tried R-3.5.0 and R-3.5.1 Linux versions.
|> >>
|> >>In case it's material ...
|> >>
|> >>I couldn't get the scraping to work on either of the R installations
|> >>but Windows users told me it worked for them.  So I thought I'd get
|> >>the R object and use it.  I could understand accessing the web address
|> >>could have different permissions for different OSes, but should that
|> >>affect the R objects?
|> >>
|> >>TIA
|> >>
|> >>--
|> >>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> >>___Patrick Connolly
|> >>  {~._.~}   Great minds discuss ideas
|> >>  _( Y )_ Average minds discuss events
|> >>(:_~*~_:)  Small minds discuss people
|> >>  (_)-(_)  . Eleanor Roosevelt
|> >>
|> >>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> >>
|> >>__
|> >>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.
|> >>
|> >[[alternative HTML version deleted]]
|> >
|> >__
|> >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.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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.


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>> wrote:
>
> 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
> > rawData
> [1] "rawData" # only the name and something to make up 112 bytes
> >
>
> Have I misunderstood the syntax?
>
> It's an old version on Windows.  I haven't used Windows R since then.
>
> major          3
> minor          2.4
> year           2016
> month          03
> day            16
>
>
> I've tried R-3.5.0 and R-3.5.1 Linux versions.
>
> In case it's material ...
>
> I couldn't get the scraping to work on either of the R installations
> but Windows users told me it worked for them.  So I thought I'd get
> the R object and use it.  I could understand accessing the web address
> could have different permissions for different OSes, but should that
> affect the R objects?
>
> TIA
>
> -- 
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>
>    ___    Patrick Connolly
>  {~._.~}                   Great minds discuss ideas
>  _( Y )_                 Average minds discuss events
> (:_~*~_:)                  Small minds discuss people
>  (_)-(_)                              . Eleanor Roosevelt
>
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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.


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 of saving/reading objects.


Rgds,

Robert


On 07/11/18 08:13, 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 
wrote:


 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

rawData

[1] "rawData" # only the name and something to make up 112 bytes
Have I misunderstood the syntax?

It's an old version on Windows.  I haven't used Windows R since then.

major  3
minor  2.4
year   2016
month  03
day16


I've tried R-3.5.0 and R-3.5.1 Linux versions.

In case it's material ...

I couldn't get the scraping to work on either of the R installations
but Windows users told me it worked for them.  So I thought I'd get
the R object and use it.  I could understand accessing the web address
could have different permissions for different OSes, but should that
affect the R objects?

TIA

--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
___Patrick Connolly
  {~._.~}   Great minds discuss ideas
  _( Y )_ Average minds discuss events
(:_~*~_:)  Small minds discuss people
  (_)-(_)  . Eleanor Roosevelt

~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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.


[[alternative HTML version deleted]]

__
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.


__
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.


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 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
> > rawData
> [1] "rawData" # only the name and something to make up 112 bytes
> >
>
> Have I misunderstood the syntax?
>
> It's an old version on Windows.  I haven't used Windows R since then.
>
> major  3
> minor  2.4
> year   2016
> month  03
> day16
>
>
> I've tried R-3.5.0 and R-3.5.1 Linux versions.
>
> In case it's material ...
>
> I couldn't get the scraping to work on either of the R installations
> but Windows users told me it worked for them.  So I thought I'd get
> the R object and use it.  I could understand accessing the web address
> could have different permissions for different OSes, but should that
> affect the R objects?
>
> TIA
>
> --
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>___Patrick Connolly
>  {~._.~}   Great minds discuss ideas
>  _( Y )_ Average minds discuss events
> (:_~*~_:)  Small minds discuss people
>  (_)-(_)  . Eleanor Roosevelt
>
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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.


[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
> rawData
[1] "rawData" # only the name and something to make up 112 bytes
> 

Have I misunderstood the syntax?

It's an old version on Windows.  I haven't used Windows R since then.

major  3  
minor  2.4
year   2016   
month  03 
day16 


I've tried R-3.5.0 and R-3.5.1 Linux versions.

In case it's material ... 

I couldn't get the scraping to work on either of the R installations
but Windows users told me it worked for them.  So I thought I'd get
the R object and use it.  I could understand accessing the web address
could have different permissions for different OSes, but should that
affect the R objects?

TIA

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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.