Re: [R] read.xls: number of sheets

2009-07-02 Thread William Dunlap
:r-help-boun...@r-project.org] On Behalf Of Lauri Nikkinen > Sent: Thursday, July 02, 2009 10:23 AM > To: Henrique Dallazuanna > Cc: r-h...@stat.math.ethz.ch > Subject: Re: [R] read.xls: number of sheets > > Thanks, I tried and got this error: > > > setwd("C:/")

Re: [R] read.xls: number of sheets

2009-07-02 Thread Lauri Nikkinen
Thanks, it did not work but this worked: xl$Workbooks()$Open("\\sample_file.xls")$Sheets()$Count() Cheers, Lauri 2009/7/2 Henrique Dallazuanna : > Try this: > > xl$Workbooks()$Open("/sample_file.xls")$Sheets()$Count() > > On Thu, Jul 2, 2009 at 2:23 PM, Lauri Nikkinen > wrote: >> >> Thanks, I t

Re: [R] read.xls: number of sheets

2009-07-02 Thread Henrique Dallazuanna
Try this: xl$Workbooks()$Open("/sample_file.xls")$Sheets()$Count() On Thu, Jul 2, 2009 at 2:23 PM, Lauri Nikkinen wrote: > Thanks, I tried and got this error: > > > setwd("C:/") > > list.files(pattern=".xls") > [1] "sample_file.xls" > > library(RDCOMClient) > > xl <- COMCreate("Excel.Application

Re: [R] read.xls: number of sheets

2009-07-02 Thread Lauri Nikkinen
Thanks, I tried and got this error: > setwd("C:/") > list.files(pattern=".xls") [1] "sample_file.xls" > library(RDCOMClient) > xl <- COMCreate("Excel.Application") > xl$Workbooks()$Open("sample_file.xls")$Sheets()$Count() Error in .COM(x, name, ...) : 'sample_file.xls' could not be found. Check

Re: [R] read.xls: number of sheets

2009-07-02 Thread Gabor Grothendieck
A second possibility (not as automated but very simple to do) is to read the first sheet with verbose = TRUE: DF <- read.xls("test.xls", sheet = 1, verbose = TRUE) and it will display the number of sheets in a message. You can then read them in in a loop. On Thu, Jul 2, 2009 at 11:05 AM, Gabor

Re: [R] read.xls: number of sheets

2009-07-02 Thread Gabor Grothendieck
If you are on Windows and have Excel on the same machine then the code here: http://tolstoy.newcastle.edu.au/R/e6/help/09/03/7736.html will return the number of worksheets as well as a vector of the worksheet names. It seems that the email has somehow caused some of the lines to wrap so you will

Re: [R] read.xls: number of sheets

2009-07-02 Thread Henrique Dallazuanna
Try this: library(RDCOMClient) xl <- COMCreate("Excel.Application") xl$Workbooks()$Open("teste.xls")$Sheets()$Count() On Thu, Jul 2, 2009 at 11:22 AM, Lauri Nikkinen wrote: > Hi, > > I'm trying to read several Excel sheets from an Excel file into a > list. I'm using > read.xls from package 'g

[R] read.xls: number of sheets

2009-07-02 Thread Lauri Nikkinen
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