[R-SIG-Mac] Clipboard

Timothy Bates tim.bates at ed.ac.uk
Wed May 16 10:07:47 CEST 2007

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

> Error in open.connection(file, "r") : unable to open connection
> In addition: Warning message:
> Clipboard cannot be opened or contains no text

And instead we have to do:

my.data <- read.table(pipe("pbpaste"), header=TRUE)

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 would seem especially valuable as it will help scripts stay
cross-platform. The only drawback i can see if that you couldn't access
files called "clipboard" stored in the target directory, but that seems no
practical loss.


More information about the R-SIG-Mac mailing list