Writing a single output file
input <- do.call(rbind, lapply(fileNames, function(.name){
+ ? ? .data <- read.table(.name, header = TRUE, as.is = TRUE) + ? ? # add file name to the data + ? ? .data$file <- .name + ? ? .data + }))
You can simplify this a little with plyr: fileNames <- list.files(pattern = "file.*.csv") names(fileNames) <- fileNames input <- ldply(fileNames, read.table, header = TRUE, as.is = TRUE) Hadley
Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/