[R] read.xls: number of sheets

Lauri Nikkinen lauri.nikkinen at iki.fi
Thu Jul 2 16:22:42 CEST 2009


Hi,

I'm trying to read several Excel sheets from an Excel file into a
list. I'm using
read.xls from package 'gdata'. I would like to know how I can
check the number of sheets before the loop (in the example below) so
that I could adjust the loop counter? Any suggestions?

DF.list <- list()
for (i in 1:4) {
    DF.list[[i]] <- read.xls("sample_file.xls", sheet=i,
stringsAsFactors = FALSE)
    }

Thanks,
-L




More information about the R-help mailing list