rajclinasia escribió:
Hi Every one,
my question is, How to Import more than one sheet in a single excel file
(e.g. 10 sheets in one excel file) into R and create datasets for all the
sheets in a single excel file without specifying the sheetnames.
Thank you in Advance.
Hello,
One way is to use the read.xls() function from package gdata. You will
need to have Perl installed (one easy choice is
http://www.activestate.com/activeperl), and you can only read Excel <
2003 files (not 2007). After running this code, you can merge the
resulting list of datafremes with the merge() function. Be sure to have
a column in each Sheet in the .xls file that corresponds to
subject/observation, with the same name [see ?merge ]. Then you can use
the write(), write.table() or write.csv() functions for exporting the
resulting data frame to an Excel readable 1 sheet only file.
xls <- file.choose() #Choose the .xls file to convert
prl <- file.choose() #Choose the perl.exe file location
example:"C:/Perl/bin/perl.exe"
sheet <- list()
for(i in 1:10){
sheet[[i]] <- read.xls(f, sheet=i, perl=prl)
}
If you plan to use Excel and R a lot, I sincerely recommend using Rexel,
from http://rcom.univie.ac.at/download.html, it is a great package.
Keo.
Mexico City.
______________________________________________
R-help@r-project.org 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.