On Mon, Jan 25, 2010 at 4:43 AM, Paul Hiemstra <p.hiems...@geo.uu.nl> wrote: > Brad Patrick Schneid wrote: >> >> ### The following is very helpful ######### listOfFiles <- >> list.files(pattern= ".txt") d <- do.call(rbind, lapply(listOfFiles, >> read.table)) ############################### >> >> but what if each file contains information corresponding to a different >> subject and I need to be able to tell where each row came from? i.e.: I >> need a new row > > a new column I presume, not a row >> >> that repeats the original filename for each observation of >> the former respective files. >> >> Any ideas? >> >> > > listOfFiles <- list.files(pattern= ".txt") > d <- do.call(rbind, lapply(listOfFiles, read.table))
Or use the plyr package: listOfFiles <- list.files(pattern= ".txt") names(listOfFiles) <- basename(listOfFiles) d <- ldply(listOfFiles, read.table) See http://had.co.nz/plyr for more info. Hadley -- http://had.co.nz/ ______________________________________________ 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.