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]]
http://cran.r-project.org/doc/manuals/R-data.html#Reading-Excel-spreadsheets plus there is a package xlsReadWrite that might be of your interest. Stefan -------- Original Message -------- Subject: [R] R-excel From: Erika Frigo <erika.frigo at unimi.it> To: r-help at stat.math.ethz.ch Date: 25.06.2007 14:47> 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. > > ------------------------------------------------------------------------ > > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.472 / Virus Database: 269.9.6/865 - Release Date: 24.06.2007 08:33 >
cf. R Data Import/Export <file:///tmp/RtmpnFqONj/.R/doc/manual/R-data.html>in the standard documentation. Christophe On 6/25/07, Erika Frigo <erika.frigo@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@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. > >-- Christophe Pallier (http://www.pallier.org) [[alternative HTML version deleted]]
Hi, Directly import from Excel files should be possible using the RODBC package. Yu may want to read the "R data import/export" manual about the RODBC package for further details. Another solution is to save each of your Excel sheets as *.csv file and import the data in R using the read.table command (see ?read.table). Sebastien Erika Frigo a écrit :> 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@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. >[[alternative HTML version deleted]]
Also try xlsReadWrite package on CRAN. --- 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. >
The R(D)COM server (contaiong the RExcel Excel addin) and/or the rcom package allow (among other things) to select a range in Excel and directly transfer it to R as an array or as a dataframe. It only works on Windows with Excel and R installed. More information on these packages is available at http://rcom.univie.ac.at Erika Frigo 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.-- Erich Neuwirth, Didactic Center for Computer Science University of Vienna Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-9394
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.
I am running R 2.5.1 using Mac OSX 10.4.10. "xlsReadWrite" is a Windows binary. Instead, install and load packages: (1) "gtools":(2) "gdata". These are both Windows and Mac binaries. "gdata" depends on "gtools", so be sure to load "gtools" first or set the installation depends parameters. Then you can use "read.xls". Thus, in Mac: "data<-read.xls("/Users/your name/Documents/data.xls",sheet=1). For Windows, substitute the appropriate filepath and file name in the first argument of "read.xls": e.g., "data<-read.xls("A:/filename.xls",sheet-1)". Thanks to correspondents for their advice; but I hope that this may alleviate some of the frustration (referred to in the R Import/Export Manual) associated with dealing with EXCEL files in R. Erika Frigo 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. > >-- View this message in context: http://www.nabble.com/R-excel-tf3975982.html#a12101349 Sent from the R help mailing list archive at Nabble.com.