[R] read.table from a list of filenames

Liaw, Andy andy_liaw at merck.com
Tue Dec 28 23:55:46 CET 2004


The solution is in section 7.21 of the R FAQ.  BTW, `rf' is a built-in R
function for generating random numbers from an F distribution, so better use
some other name.

Andy

> From: thomas hills
> 
> I am wondering if it is possible to read.table repeatedly from a list 
> of file names into a new list of table names.
> 
> For example:
> 
> filenames <- list.files()
> 
> then with a function like
> 
> rf <- function(i) {
> word??(filename[i]) <- read.table(filenames[i]) }
> 
> I can't seem to find a function like word?? that will be the 
> object of 
> another operation.   If this worked, then I could repeat it for the 
> length of filenames.
> 
> Also, even the following function seems to give me an error, but I 
> don't yet know why.
> 
> rf <- function(nam, i) {  nam <- read.table(filenames[i]) }
> 
> 
> Any help would be very much appreciated.
> 
> Thanks,
> Thomas
> 	[[alternative text/enriched version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list