[R] R-excel

Stephen Tucker brown_emu at yahoo.com
Tue Jun 26 07:49:04 CEST 2007


There are also some notes about this in the R Data Import/Export manual: 
http://cran.r-project.org/doc/manuals/R-data.html#Reading-Excel-spreadsheets

But I've gathered the following examples from the R-help mailing list
archives [in addition to the option of saving the spreadsheet as a .csv file
and reading it in with read.csv()]. Personally, I use option 4 regularly (I
happened to have Perl installed on my Windows XP machine already) and have
had good luck with it.

Hope this helps.

========= Option 1 =========
# SIMPLEST OPTION
install.packages(xlsReadWrite)
library(xlsReadWrite)
data = read.xls("sampledata.xls",sheet=1)

========= Option 2 =========
# ALSO SIMPLE BUT MORE MANUAL WORK EACH TIME
# (1) highlight region in Excel you want to import and
data = read.delim(file="clipboard",header=TRUE)
# or, if you don't have a header,
data = read.delim(file="clipboard",header=FALSE)

========= Option 3 =========
# RODBC IS A BIG APPLICATION, FOR INTERFACING
# WITH MANY TYPES OF FILES/SERVERS
install.packages(RODBC)
library(RODBC)
fid <- odbcConnectExcel("sampledata.xls")
data <- sqlFetch(fid,"Sheet1")
close(fid)

========= Option 4 =========
# REQUIRES CONCURRENT INSTALLATION OF PERL
install.packages(gdata)
library(gdata)
data = read.xls("sampledata.xls",sheet=1)

============================ 



--- Erika Frigo <erika.frigo at unimi.it> wrote:

> 
> Good morning to everybody,
> I have a problem : how can I import excel files in R???
> 
> thank you very much
> 
> 
> Dr.sa. Erika Frigo
> Università degli Studi di Milano
> Facoltà di Medicina Veterinaria
> Dipartimento di Scienze e Tecnologie Veterinarie per la Sicurezza
> Alimentare (VSA)
>  
> Via Grasselli, 7
> 20137 Milano
> Tel. 02/50318515
> Fax 02/50318501
> 	[[alternative HTML version deleted]]
> 
> > ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
> 



       
____________________________________________________________________________________

Comedy with an Edge to see what's on, when.



More information about the R-help mailing list