Skip to content
Prev 207389 / 398506 Next

read multiple large files into one dataframe

###  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 that repeats the original filename for each observation of
the former respective files.

Any ideas?