import data
I agree with Simon that copy paste is the easiest way to go.
However, because I was unable to remember the
read.table(pipe("pbpaste")) command and wanted to
give instructions to students that were platform
independent, I created a little function
(read.clipboard) that works on PCs or Macs . It
is available in the psych package:
"read.clipboard" <-
function(header=TRUE,...) {
MAC<-Sys.info()[1]=="Darwin" #are we on a Mac using the Darwin system?
if (!MAC ) {if (header)
read.clipboard<-read.table(file("clipboard"),header=TRUE,...)
else read.clipboard<-read.table(file("clipboard"),...) }
else {
if (header) read.clipboard<- read.table(pipe("pbpaste"),header=TRUE,...)
else read.clipboard<- read.table(pipe("pbpaste"),...)}
}
With the addition of a sep="," option, it can also read csv copied files:
"read.clipboard.csv" <-
function(header=TRUE,sep=',',...) { #same as read.clipboard(sep=',')
MAC<-Sys.info()[1]=="Darwin" #are we on a Mac using the Darwin system?
if (!MAC ) {if (header)
read.clipboard<-read.table(file("clipboard"),header=TRUE,sep,...)
else read.clipboard<-read.table(file("clipboard"),sep,...) }
else {
if (header) read.clipboard<-
read.table(pipe("pbpaste"),header=TRUE,sep,...)
else read.clipboard<- read.table(pipe("pbpaste") ,sep,...)}
}
Bill
At 10:53 AM -0400 6/13/08, Simon Urbanek wrote:
On Jun 13, 2008, at 4:43 AM, Emiliano Guevara wrote:
Hi, There's many ways to do it. I would suggest using comma separated values as a "bridge" filetype.
I find copy/paste more convenient for most
simple tables - simply select the table in
Numbers, press <Cmd><C> (Copy) and then read the
clipboard in R:
read.table(pipe("pbpaste"))
Cheers,
Simon
From Numbers, save your data as a .csv file (comma separated value). Then, in R, import the data from the file using:
read.csv(file.csv)
That should be it, Best wishes, E. On Jun 13, 2008, at 05:34 AM, Peng Jiang wrote:
Hi , I have some data in Numbers, which is a data managing software for Mac OS. How can I import them to R ? Or how can I import my data from R to Numbers ? Any interfaces between R and Numbers or something ? I am a newbie so if the question is toooooo simple, please take it easy. Thanks! -------------------------- Peng Jiang ?]?? Ph.D. Candidate Antai College of Economics & Management ?????????????w?@ Department of Mathematics ???w?n Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China
**************************************** Emiliano R. Guevara Facolt? di Lingue e Lett. Straniere Dipart. di Lingue e Lett. Straniere Universit? di Bologna Via Cartoleria 5 (40124) Bologna, Italia http://morbo.lingue.unibo.it/ emiliano.guevara at unibo.it emiguevara at gmail.com
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-mac
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-mac
William Revelle http://personality-project.org/revelle.html Professor http://personality-project.org/personality.html Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ Attend ISSID/ARP:2009 http://issid.org/issid.2009/