Entering edit mode
7.1 years ago
zizigolu
★
4.3k
Hi,
I have six data sets from different platforms, I annotated probs in each data to gene symbole. I want to merge them like so I have six data sets with the same gene symbols in rows. I used intertection but data sets returned NA. how to match these data?
I thought about merging one by one
merge(data1,data2,by="first col.name")
then extracting each data from merged one but that returned a data without genes in rows
when I tried to merge all
> merge=merge(data1,data2,data3,data4,data5,data6,by="ID")
Error in fix.by(by.x, x) :
'by' must specify one or more columns as numbers, names or logical
but all have ID in first col.name
I should merged one by one but
merged=merge(data1,data2,by="first col.name")
data1=merged[,1:43]
data2=merged[1,44:150] gives just one observation
.
.
To merge dataframes (DF) by row names, use DF=merge(DF1,DF2,by="row.names"). Also, you cannot merge multiple DF like this unless you store them into a list. Make a loop and iterate on each DF you want to merge or create a list of DF and use join_all function from plyr package (https://www.rdocumentation.org/packages/plyr/versions/1.8.4/topics/join_all).
thank you,
I can exteact DF1 from DF by
DF1=DF[,1:42]
but for extracting DF2 ---->DF2=DF[1,43:150]
gives only one observation andDF2=DF[,43:150]
gives no genes in rows. how extract DF2 which contains row names also?I don't understand what kind of structure do want to process and obtain. I mean, it seems like your DF is already merged so why sub-setting DF1 with the first 42 columns and DF2 with other columns but a single line?
because I need each of DF1 and DF1 independently