[R-SIG-Mac] import data

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jun 13 17:46:16 CEST 2008


On Fri, 13 Jun 2008, Simon Urbanek wrote:

> I agree that the difference between Mac and others WRT clipboard is a bit 
> annoying. I'll see if I can fix that.

If you do, can you leave a way to read from the X11 primary selection for 
those who like to use X11 applications on Mac OS?  I'm not objecting to 
file="clipboard" changing its meaning, but "X11_clipboard" is taken, so 
perhaps "X11_primary" or some such.

Brian

>
> Thanks,
> Simon
>
> On Jun 13, 2008, at 11:16 AM, William Revelle wrote:
>
>> 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/
>> 
>> 
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

-- 
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-SIG-Mac mailing list