Use a list instead of assign then do.call("rbind", thelist).

import.files <- c("a.txt", "b.txt",  "c.txt",  "d.txt",  "e.txt")
imp <- vector("list", length(import.files))
for (i in 1:length(import.files)) {
  imp[[i]] <- read.delim(import.files[i], sep = "", header = TRUE)
}

combined <- do.call("rbind", imp)

HTH,

--sundar

On Mon, Jan 4, 2010 at 4:31 PM, Steven Kang <stochastick...@gmail.com>wrote:

> Hi, all
>
> Basically, I have unknown number of data that need to be imported and
> collapsed row-wisely.
>
> The code below works fine, however the "rbind" function may require 50
> arguments if there are 50 data files...
>
> Thus, I would like to explore whether there are any methods in using
> dynamic
> objects (i.e from the resulting objects in the for loop) as an argument in
> the *"rbind"* function.
>
>
>
> setwd(.........)
>
> import.files <- c("a.txt", "b.txt",  "c.txt",  "d.txt",  "e.txt")
> for (i in 1:length(import.files)) {
>      assign(paste("imp", i, sep = "."), read.delim(eval(paste(".\\",
> import.files[i], sep = "")), header = TRUE))
> }
>
> combined <- rbind(*imp.1, imp.2, imp.3, imp.4, imp.5, imp.6*)
>
>
>
> Your expertise in resolving this issue would be greatly appreciated.
>
>
>
> Steve
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to