[R-SIG-Mac] Clipboard

Simon Urbanek simon.urbanek at r-project.org
Wed May 16 16:43:17 CEST 2007

On May 16, 2007, at 4:07 AM, Timothy Bates wrote:

> Hi there,
> This command  to use the clipboard as a data source used (pre 2.4?)
> to work on OS X:
>  my.data <- read.table(file("clipboard"),header=TRUE)
>  my.data <- read.table("clipboard", header=TRUE)
> Now (2.5) the above forms generate an error

Nothing really changed, it still works even in R 2.5.0 if you use X11  
(as Ken pointed out).

> And instead we have to do:
> my.data <- read.table(pipe("pbpaste"), header=TRUE)

That works with any Mac pasteboard.

> I wonder as this is quite a nice feature, and widely used, if the  
> PC version should not be emulated on the mac (i.e., both the os x  
> terminology "pbpaste" and the generic and user friendly "clipboard"  
> work?

It is not trivial, because a file and a pipe are different connection  
types and when you use file("clipboard"), it could mean either pipe 
("pbpaste") or pipe("pbcopy","w"), so the purpose it not clear until  
you actually open the connection.

IMHO a more clean solution would be to provide a dedicated clipboard 
() function which would create a clipboard connection, regardless of  
the platform.


More information about the R-SIG-Mac mailing list