[Rd] accessing windows clipboard from load and save (PR#4999)

Duncan Murdoch dmurdoch at pair.com
Sat Nov 8 16:40:54 MET 2003


On Sat,  8 Nov 2003 15:21:48 +0100 (CET), you wrote:

>Full_Name: Gabor Grothendieck
>Version: 1.7.1
>OS: Windows 2000
>Submission from: (NULL) (207.35.143.81)
>
>
>
>   save(x,ascii=TRUE,file("clipboard")) 
>
>works but 
>
>   load(file("clipboard")) 
>
>does not.

This is a documented limitation of the clipboard connection (which is
write-only), not a bug.  Yes, it would be nice if all clipboard
functions were supported, but they're not.  

>Even better would be if
>
>   save(x,ascii=TRUE,"clipboard") 
>and 
>   load("clipboard")
>
>worked as that would provide consistency with read.table("clipboard")

Is this documented somewhere?  I didn't know about it (but it does
work).

Personally, I'd rather have a connection created by a function named
clipboard(); it looks kludgy to interpret some filenames as magic
values.  Then your examples would be

save(x,ascii=TRUE,file=clipboard('w')) 

load(clipboard())

read.table(clipboard())

Another special connection (which might exist? I couldn't spot it)
would be one that read from a character vector, i.e. c('a','b','c')
would be read as 3 lines of one letter each.  Then something like

 stringConnection(readClipboard()) 

would be one way to implement clipboard().

Duncan Murdoch



More information about the R-devel mailing list