Using eval-parse for this looks like overkill. You should just be able to
do something straightforward like:
for (i in 1:120)
assign(paste("book", i, sep=""), read.xls(paste("Book", i, ".xls",
sep=""), sheet=1, from=4, colClasses="numeric"))
which would put your spreadsheets in variables bo
el Anyadike-Danes
Cc: r-help@r-project.org
Subject: Re: [R] using eval-parse-paste in a loop
> ### stripping off eval, looking for clues
>
>
>
> parse(paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="numer
> ic")
Michael -
>
> 3. Equally, advice about a better approach would also be v. welcome.
>
As an alternative approach, you may want to save the sheet names in a
list and then use the lapply function to read your data into a list.
This would greatly reduce the 'clutter' of objects in your global
> ### stripping off eval, looking for clues
>
>
>
> parse(paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="numer
> ic")',sep=''))
>
> Error in file(file, "r") : unable to open connection
>
> In addition: Warning message:
>
> In file(file, "r") :
>
> cannot open fi
R-helpers
I have 120 small Excel sheets to read and I am using
library(xlsReadWrite): one example below.
I had hoped to read sheets by looping over a list of numbers in their
name (eg Book1.xls, Book2.xls, etc).
I thought I had seen examples which used eval-parse-paste in this way.
5 matches
Mail list logo