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

Duncan Murdoch dmurdoch at pair.com
Sat Nov 8 17:45:35 MET 2003


On Sat, 8 Nov 2003 16:03:19 +0000 (GMT), you wrote:

>On Sat, 8 Nov 2003, Duncan Murdoch wrote:
>
>> 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()) 
>
>It's called a textConnection:
>
>> readLines(textConnection(c('a','b','c')))
>[1] "a" "b" "c"
>
>The problem here is not with the file("clipboard") connection but with the
>documented restriction of load() to suitable connections, including
>needing binary mode (which text connections don't have either).

I was misled by a typo in the man page for file, where it says:

    Under Windows, 'file' can also be used with 'description =
    "clipboard"' in mode '"w"' and '"w"' only.

Presumably that should be "in modes '"r"' and '"w"'."

In the ?load page, I see the words "suitable connection", but I don't
see any mention of binary access being required.  Is that documented
somewhere?

I guess it comes from the use of gzcon in load.  Couldn't the
restriction be removed by having gzcon treat any text mode connection
as uncompressed?

Duncan Murdoch



More information about the R-devel mailing list