[R] problems with clipboard

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 28 19:50:00 CEST 2009


On Tue, 28 Apr 2009, Jamie.lannister wrote:

>
> Hi I'm a mac user. I have problems loading data from mac excel in R.
> I'm using these script:
>> library(utils)
>> data2 <- read.table(file("clipboard"), header =T, sep ="\t")
> ____but this is the message that I have from R_____
> Error in open.connection(file, "r") : cannot open the connection
> In addition: Warning message:
> In open.connection(file, "r") :
>  clipboard cannot be opened or contains no text
>
> More complicate then that is that sometimes it works sometimes no.......
> I'm very confuse.... any help?

See the help for 'file'.  It says (on a Mac) that file("clipboard") 
reads the 'X11 primary selection', and also says

      Mac OS X users can use 'pipe("pbpaste")' and 'pipe("pbcopy", "w")'
      to read from and write to that system's clipboard.

The problem is that most windows managers on Unix-alikes have multiple 
clipboards and working out which text is in which clipboard is tricky, 
not least as some applications (and some window managers) try to be 
helpful and copy to more than one clipboard.  That's why this may 
sometimes appear to work and sometimes not.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list