s-news
[Top] [All Lists]

Re: Importing multiple .xls files?

To: Sarah Henderson <sarah.henderson@ubc.ca>, s-news@lists.biostat.wustl.edu
Subject: Re: Importing multiple .xls files?
From: "Richard M. Heiberger" <rmh@temple.edu>
Date: Sat, 16 Jul 2005 22:56:31 -0400
## I created simple Excel files test1.xls and test3.xls in the
## directory in which my working .Data sits.
## Then I imported them in a loop.
## file.exists() allows me to go through the number sequence and lets
## the S-Plus program figure out whether there is a corresponding file.


objects(p="test[12345]")

for (i in 1:5) {
  name <- paste("test", i, sep="")
  name.i <- paste(name, ".xls", sep="")
  if (file.exists(name.i)) assign(name, importData(name.i))
}

objects(p="test[12345]")


Rich

<Prev in Thread] Current Thread [Next in Thread>