I have data frames generated by lapply
with distinct element names.
head(df1)
$Sample1
G1 G2 Group
1 1.016673 -1.04402692 1
2 1.019958 -0.86763046 1
3 1.033050 -1.09717438 1
4 1.036969 0.26971351 1
5 1.044059 1.73402959 1
$Sample2
G1 G2 Group
1 1.413218 0.22466456 1
2 1.413339 -0.91755436 1
3 1.415782 -0.23471118 1
4 1.434750 -0.77498973 1
5 1.436905 0.76642626 1
Another set is similar in format, specified by 2 under Group
head(df2)
$Sample1
G1 G2 Group
1 1.053269 -1.04460950 2
2 1.059461 -0.86711232 2
3 1.072446 -1.09748431 2
4 1.078763 0.26785751 2
5 1.038325 1.73818175 2
$Sample2
G1 G2 Group
1 1.438067 0.22933986 2
2 1.856085 -0.91988726 2
3 1.415782 -0.23405677 2
4 1.434750 -0.77406530 2
5 1.436905 0.76078091 2
My goal is to combine/merge them together by element names, for example Sample1
and Sample2
.
$Sample1
G1 G2 Group
1 1.016673 -1.04402692 1
2 1.019958 -0.86763046 1
3 1.033050 -1.09717438 1
4 1.036969 0.26971351 1
5 1.044059 1.73402959 1
1 1.053269 -1.04460950 2
2 1.059461 -0.86711232 2
3 1.072446 -1.09748431 2
4 1.078763 0.26785751 2
5 1.038325 1.73818175 2
$Sample2
G1 G2 Group
1 1.413218 0.22466456 1
2 1.413339 -0.91755436 1
3 1.415782 -0.23471118 1
4 1.434750 -0.77498973 1
5 1.436905 0.76642626 1
1 1.438067 0.22933986 2
2 1.856085 -0.91988726 2
3 1.415782 -0.23405677 2
4 1.434750 -0.77406530 2
5 1.436905 0.76078091 2
I could not figure out how to do this. Could someone help me? Thanks!