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? Jamie -- View this message in context: http://www.nabble.com/problems-with-clipboard-tp23280578p23280578.html Sent from the R help mailing list archive at Nabble.com.
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:> > 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? > > Jamie > -- > View this message in context: http://www.nabble.com/problems-with-clipboard-tp23280578p23280578.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
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