Hi:

Here's a toy example: the first part is to create files and write them out
to the current directory.

# Create a dummy file and run it five times, creating five new .csv files
file <- data.frame(x = rnorm(5), y = rnorm(5))
fnames <- paste('file', 1:5, '.csv', sep = '')
# last column is an indicator of the file number
for(i in seq_along(fnames)) write.csv(cbind(file, gp = rep(i, 5)), file =
fnames[i])

# Now read them back into R and row concatenate them:

# Method 1:

# read the data files into a list
 l <- lapply(fnames, read.csv)
# row concatenate them together
do.call(rbind, l)

# Method 2:
# Use package plyr to slurp the files together:

library(plyr)
ldply(fnames, read.csv)

HTH,
Dennis

On Thu, Oct 14, 2010 at 8:16 PM, <aeneas24@priest.com> wrote:

>
> Hi,
>
> This feels like a kinda dumb basic question, but I haven't been able to
> figure it out.
>
> I have a bunch of csv files I'd like to put into one csv using R.
>
> I have tried cat, append, join, aggregate, and a bunch of other things, but
> none of them really work for combining the data. If it's one of those
> listed, then my syntax is goofy. The csv files have different row numbers
> but the same columns. I just want to add each one to the end of the other.
>
> I've removed the heading from all but one of them (but I could easily get
> the headings all back if that helps).
>
> Thanks for the help!
>
> Tyler
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]

