Hi.
merge has parameters all, all.x and all.y which should specify if you want to use common or all values from the data frame. Cheers Petr > -----Original Message----- > From: R-help <r-help-boun...@r-project.org> On Behalf Of pooja sinha > Sent: Tuesday, December 15, 2020 11:14 PM > To: Bert Gunter <bgunter.4...@gmail.com> > Cc: r-help mailing list <r-help@r-project.org> > Subject: Re: [R] merging multiple .csv files > > I know that but I do not want to merge them sequentially because I may lose > some rows which are present in one file while the other doesn't have. I > googled and found something called multmerge but the code is not working > for me. I used the following: > > path <-"P:/Documents/Puja Desktop items/Documents/RESULTS/est meth > results/Final_est_meth_data_rn6/WGBS_exon_sort_CHG/merge_csv" > > > filenames <- list.files(path = path) > > View(filenames) > multmerge = function(path){ > filenames=list.files(path=path, full.names=TRUE) > datalist = lapply(filenames, function(x){read.csv(file=x,header=T)}) > Reduce(function(x,y) {merge(x,y)}, datalist) > } > > full_data = multmerge("~/P:/Documents/Puja Desktop > items/Documents/RESULTS/est meth > results/Final_est_meth_data_rn6/WGBS_exon_sort_CHG/merge_csv") > > But after running the full_data, the folder is empty. > > Thanks, > Puja > > On Tue, Dec 15, 2020 at 4:51 PM Bert Gunter <bgunter.4...@gmail.com> > wrote: > > > ?read.csv to read your csv files in data frames > > ?merge to merge them (sequentially). > > > > > > Bert Gunter > > > > "The trouble with having an open mind is that people keep coming along > and > > sticking things into it." > > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > > > > On Tue, Dec 15, 2020 at 1:36 PM pooja sinha <pjsinh...@gmail.com> > wrote: > > > >> Hi All, > >> > >> I have 10 .csv files containing 12 to 15 columns but have some columns in > >> common. I need to join all of my .csv files into one using one common > >> column ‘Pos’. The header portion of my .csv files looks as shown below: > >> > >> Chrom Pos Avg Stdev A15_3509.C A31_3799.C A32_3800.C A35_3804.C > Gene ID > >> Class ExNum > >> > >> Can anyone help me in getting the code for the above problem. Any help > >> will be highly appreciated. > >> > >> > >> Thanks, > >> > >> Puja > >> > >> [[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.
______________________________________________ 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.