I have these matrices of different dimensions. The key.related.sheet
column in all matrices have some common and some uniques values. I want to match those common rows and merge all three matrices, but I also want to include unique rows as well. The result column should have key.related.sheet
, Sample_B
and trace_1
,trace_2
and trace_3
columns only. Can someone please help me with this?
aa<-structure(c("S05-F13-P01:S05-F13-P01", "S05-F13-P01:S08-F10-P01",
"S05-F13-P01:S08-F11-P01", "S05-F13-P01:S09-F66-P01", "S05-F13-P01",
"S08-F10-P01", "S08-F11-P01", "S09-F66-P01", "1.25", "0.227",
"-0.183", "-0.217"), .Dim = c(4L, 3L), .Dimnames = list(NULL,
c("key.related.sheet", "sample_B", "trace_1")))
bb<-structure(c("S05-F13-P01:S08-F10-P01", "S05-F13-P01:S08-F11-P01",
"S05-F13-P01:S09-F66-P01", "S05-F13-P01:S09-F67-P01", "S08-F10-P01",
"S08-F11-P01", "S09-F66-P01", "S09-F67-P01", "0.227", "-0.183",
"-0.217", "0.292", "Unknown", "Unknown", "Unknown", "Unknown"
), .Dim = c(4L, 4L), .Dimnames = list(NULL, c("key.related.sheet",
"sample_B", "trace_2", "type")))
cc<-structure(c("S05-F13-P01:S08-F11-P01", "S05-F13-P01:S09-F66-P01",
"S05-F13-P01:S09-F67-P01", "S05-F13-P01:S09-F68-P01", "S05-F13-P01:S09-F01-P01",
"S08-F11-P01", "S09-F66-P01", "S09-F67-P01", "S09-F68-P01", "S09-F01-P01",
"-0.183", "-0.217", "0.292", "-0.314", "0.0418"), .Dim = c(5L,
3L), .Dimnames = list(NULL, c("key.related.sheet", "sample_B",
"trace_3")))
The expected output would be:
key.related.sheet sample_B trace_1 trace_2 trace_3
"S05-F13-P01:S05-F13-P01" "S05-F13-P01" "1.25"
"S05-F13-P01:S08-F10-P01" "S08-F10-P01" "0.227" "0.227"
"S05-F13-P01:S08-F11-P01" "S08-F11-P01" "-0.183" "-0.183" "-0.183"
"S05-F13-P01:S09-F66-P01" "S09-F66-P01" "-0.217" "-0.217" "-0.217"
"S05-F13-P01:S09-F67-P01" "S09-F67-P01" "0.292" "0.292"
"S05-F13-P01:S09-F68-P01" "S09-F68-P01" "-0.314"
"S05-F13-P01:S09-F01-P01" "S09-F01-P01" "0.0418"