Hi Xing, This depends somewhat on what you mean by "merge", and how many files you are talking about. Supposing you are dealing with few enough files you can do it manually:
dat1 <- read.csv("yourfile1.csv") dat2 <- read.csv("yourfile2.csv") ... datn <- read.csv("yourfilen.csv") If each file contains unique variables: complete.dat <- cbind(dat1, dat2, ... , datn) if each one is just a continuation rowise: complete.dat <- rbind(dat1, dat2, ... , datn) If they are all sort of related but in no consistent way, and do not need to be: complete.dat <- list(dat1, dat2, ... , datn) If you need some fancier merging than just columnwise or rowwise, look at merge(). For documentation on these features see: ?data.frame # to find out more about data frames (which is what read.csv uses) ?list # for details about what a list is ?read.table ?read.csv # just a special wrapper for read.table ?cbind # for column binding ?rbind # for row binding ?merge # for more specialized merging example(merge) # for examples using merge() HTH, Josh On Thu, Oct 7, 2010 at 8:19 PM, XINLI LI <lihaw...@gmail.com> wrote: > Dear R Group: > > How to import multiple csv files and merge into one dataset. > > Thanks and Regards, > > Xing > > [[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. > -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ ______________________________________________ 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.