[R] reading in multiple files

Sundar Dorai-Raj sdorairaj at gmail.com
Tue Jun 9 20:27:19 CEST 2009


You could try:

do.call("rbind", lapply(list.files("path/to/files", full = TRUE), read.csv))

And add more arguments to lapply if the files are not csv, have no header, etc.

--sundar

On Tue, Jun 9, 2009 at 11:18 AM, Erin Hodgess<erinm.hodgess at gmail.com> wrote:
> Dear R People:
>
> I have about 6000 files to be read in that I'd like to go to one
> matrix.  There are two columns, 1 line in each file.
>
> Is there a way to bring them in to produce one matrix or data frame, please?
>
> Thanks,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodgess at gmail.com
>
> ______________________________________________
> R-help at 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.
>




More information about the R-help mailing list