[R] save(iris,file=

Gabor Grothendieck ggrothendieck at myway.com
Thu Nov 6 01:26:16 CET 2003

I have played around with this some more and although I still do
not have a solution for loading an .rda file from the Windows
clipboard that is entirely R, with the help of the
pclip utility found at unxutils.sourceforge.net this seems
to work:

> load(pipe("pclip"))

Date: Wed, 5 Nov 2003 14:39:00 -0500 (EST) 
From: Gabor Grothendieck <ggrothendieck at myway.com>
To: <ripley at stats.ox.ac.uk>, <ggrothendieck at myway.com> 
Cc: <R-help at stat.math.ethz.ch> 
Subject: Re: [R] save(iris,file= 

I tried it using file and it seems to work for saving:

> data(iris)
> con <- file("clipboard","w")
> save(iris,ascii=T,file=con)
> close(con)
> readLines("clipboard")
... lengthy output follows which seems correct ...

but not for loading:

> con <- file("clipboard","r")
> load(con)
Error in load(con) : loading from connections not compatible with magic number

even though when I try it with real files then it works both ways:

> save(iris,ascii=T,file="myiris.rda")
> rm(iris)
> load("myiris.rda")
> ls()
... iris is back ...


Date: Wed, 5 Nov 2003 19:01:20 +0000 (GMT) 
From: Prof Brian Ripley <ripley at stats.ox.ac.uk>
To: Gabor Grothendieck <ggrothendieck at myway.com> 
Cc: <R-help at stat.math.ethz.ch> 
Subject: Re: [R] save(iris,file="clipboard",ascii=TRUE) 

As should be evident , you thought wrong (and you are thinking in the
blinkered Windows way, too).

On Windows, file() can take a filename "clipboard" in text mode only.
load() and save() are not using file(), but you could probably use it
explicitly in ASCII mode.

Don't assume your own errors are bugs in other peoples' work: it is 

On Wed, 5 Nov 2003, Gabor Grothendieck wrote:

> Is this a bug? I thought that "clipboard" could always be substituted
> for a filename when dealing with ASCII files.
> > data(iris)
> > save(iris,ascii=TRUE,file="clipboard")
> Error in file(file, "wb") : `mode' for the clipboard must be `r' or `w'
> Also this (where gclip is a utility found at unxutils.sourceforge.net
> that copies its standard input to the clipboard):
> > save(iris,ascii=TRUE,file="myiris.rda")
> > system("cmd /c gclip < myiris.rda")
> > load("clipboard")
> Error in open.connection(con, "rb") : unable to open connection
> In addition: Warning message:
> cannot open compressed file `clipboard'

No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com

More information about the R-help mailing list