Hello, I need to care excel data to be used in R,..., how do I make it? Thank you and greetings, Gerardo Prieto
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 PrietoPlease read the R Data Import/Export manual! Uwe Ligges> ______________________________________________ > 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
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 LiggesHello 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:> dator 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.
What I do, is that I save it as a file separated by tab, and read it in R using (I save it with the xls extension, because this way the file is automaticly open by excell always, althought it is a text file): read.table("file name.xls", head=T, sep="\t") it might help if you replace all the empty cells of your table (in excell) by NA cheers, Marta ----- Original Message ----- From: "Gerardo Prieto Blanco" <economia at adinet.com.uy> To: <R-help at stat.math.ethz.ch> Sent: Sunday, August 29, 2004 5:51 PM Subject: [R] importing data in excel> Hello, I need to care excel data to be used > in R,..., how do I make it? > Thank you and greetings, Gerardo Prieto > > ______________________________________________ > 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
If you need to load Excel data *into* R, you can use the read.excel() function in the gregmisc package (note that Perl must be installed) to read MS-Excel .xls files. A better option is to simply save the data out as a tab-delimited text file and then use read.table(file="<filename>", sep="\t") If you want to save R data in a form that MS-Excel will be happy with, use write.table( <object>, file="<filename>.xls", sep="\t")) -Greg -----Original Message----- From: r-help-bounces at stat.math.ethz.ch To: Gerardo Prieto Blanco Cc: R-help at stat.math.ethz.ch Sent: 8/29/04 2:04 PM Subject: Re: [R] importing data in excel 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 PrietoPlease read the R Data Import/Export manual! Uwe Ligges> ______________________________________________ > 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 LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}