[R] merging multiple .csv files
pooja sinha
pj@|nh@07 @end|ng |rom gm@||@com
Tue Dec 15 23:13:48 CET 2020
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.4567 using 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 <pjsinha07 using 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 using 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]]
More information about the R-help
mailing list