Skip to content

problems with clipboard

5 messages · Jamie.lannister, Kevin Middleton, Brian Ripley

#
Hi I'm a mac user. I have problems loading data from mac excel in R.
I'm using these script:
____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?

Jamie
#
Jamie,

Try it as:

data2 <- read.table(pipe('pbpaste'), header = T)

I have a read.clipboard() function defined in ~/.Rprofile:

read.clipboard <- function(){read.table(pipe('pbpaste'), header = T)}

Also see the "Clipboard" section of ?pipe.

Cheers,
Kevin


-------------------------------------------------
Kevin M. Middleton
Department of Biology
California State University San Bernardino
5500 University Parkway
San Bernardino CA 92407
On Apr 28, 2009, at 9:31 AM, Jamie.lannister wrote:

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

            
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.
#
Thank you very much.
I'll try.
Jamie
Kevin Middleton-3 wrote:

  
    
#
Thank you very much!
See, I'm a new user both for R and mac...... :-)

Jamie.
Prof Brian Ripley wrote: