[R] Combining many files into one

From: t c <mudiver1200_at_yahoo.com>
Date: Mon, 03 Nov 2008 18:17:10 -0800 (PST)

I have a few hundred .csv files in a folder on my hard drive, and I would like to combine them all into one file.  They are all the same data, but the program that collected the data saved a file every 4 hours.  I can combine the files one at a time using rbind, but am having a problem automating it in a for loop.  The loop runs for a while, and finally gives an error message "no lines available in input".  I would appreciate any help you can give.  What I have so far is below.  Thanks!  Tim

files<-list.files(mydir)                               #List of every file in the working directory

for (i in 1:length(files))                             #Loops through files

 dat <- read.csv(files[i], header=T)          #Reads one file at a time
 all.dat<-rbind(dat)                                  #Binds the file just read to the end of all.dat
	[[alternative HTML version deleted]]


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. Received on Tue 04 Nov 2008 - 02:34:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 04 Nov 2008 - 03:30:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive