Hi Lily, I think below codes can work:
f<- list.files("D:/output/test/your folde rname",full.names=TRUE,recursive=TRUE) files<- grep(".csv", f) files_merge<- data.frame() for (i in 1:length(f[files])){ data<- read.csv(file=f[files][i],header=TRUE, sep=",") files_merge<- rbind(files_merge,data) } Best, Lida On Thu, Jun 30, 2016 at 2:26 PM, lily li <chocol...@gmail.com> wrote: > Hi R users, > > I'd like to ask that how to merge several datasets into one in R? I put > these csv files in one folder, and use the lapply function, but it says > that cannot open file 'xx.csv'. These files have different names, but end > with .csv extension, and the files have the same header. Thanks for your > help. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.