[R] importing data in excel

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Aug 30 10:44:22 CEST 2004


The correct explanation is that 

	read.table("clipboard",header=TRUE)

(which you have entered differently and non-portably) is only
supported under Windows, as file="clipboard" is Windows-specific.
As ?bug.report and the FAQ ask, please do not report spurious 
`explanations', only facts.

The advice

> > > Please read the R Data Import/Export manual!

applies to you, too.


On Mon, 30 Aug 2004, ronggui wong wrote:

> if under  windows ,the command works well,but under linux ,it does NOT,as 
> linux can keep couples of file in clipboar.so i want to know how to do 
> similar thing under linux.anyone knows?    
> 
> the erroe msg is as follow:
> > dat<-read.table('clipboard',header=T)
> Error in file(file, "r") : unable to open connection
> In addition: Warning message:
> cannot open file `clipboard'
> 
> 
> ÔÚ 2004 °ËÔÂ 30 ÐÇÆÚÒ» 15:21£¬Thomas Petzoldt Ð´µÀ£º
> > Uwe Ligges wrote:
> > > Gerardo Prieto Blanco wrote:
> > >> Hello, I need to care excel data to be used
> > >> in R,..., how do I make it?
> > >> Thank you and greetings, Gerardo Prieto
> > >
> > > Please read the R Data Import/Export manual!
> > >
> > > Uwe Ligges
> >
> > Hello Gerardo,
> >
> > I completely agree with Uwe, and the following simple example may help:
> >
> > 1.) Create a rectangular area in Excel like this:
> >
> > no	treat	val
> > 1	a	1
> > 2	a	5
> > 3	b	3
> > 4	b	3
> > 5	b	2
> >
> > 2.) Mark and Copy these cells including the first row
> > => the data are now in the so-called "Windows Clipboard"
> >
> > 3.) Switch to R and provide the following command (by typing it!, not by
> >
> > copy and paste, because the clipboard already contains the data):
> > > dat <- read.table("clipboard", header=TRUE)
> >
> > Now, the data are in dat and you can inspect them using:
> > > dat
> >
> > or better
> >
> > > str(dat)
> >
> > Hints: depending on your configuration some additional options may be
> > necessary in read.table, e.g. sep="\t" (if your data contain empty
> > cells) or dec="," (on some non-English languages, e.g. German).
> > Furthermore there are many other ways to import data, see the manual.
> >
> > Thomas P.
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 

-- 
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