I am trying to merge multiple rows into one row. I want all samples from Group.1
with its corresponding Group.2
and cqs
data merged into one row by lot_number
.
Important detail: I have three different sample types in the Group.1
column. I think what I'm having such a hard time with is that I need to merge three different sample types into one row by lot_number
. A lot of the tools I'm aware of only merge two data tables or frames.
What I have:
Group.1 | Group.2 | cqs | lot_number |
---|---|---|---|
1xLOD_2234567 | MS2 | 39 | 2234567 |
NC_2234567 | MS2 | 37 | 2234567 |
What I need:
Group.1 | Group.2 | cqs | lot_number | (new col) | (new col) | (new col) |
---|---|---|---|---|---|---|
1xLOD_2234567 | MS2 | 39 | 2234567 | NC_2234567 | MS2 | 37 |
These are different concentration levels of solutions that I want matched up by lot number. I have tried ideas like:
aggtest2 <- reshape(aggtest2, idvar = "lot_number", timevar = "Group.2", direction = "wide"
and
aggtest0 <- reshape(aggtest2, idvar = c("lot_number","Group.2"), direction = "wide")
and I have also tried the recommendations in the two comments below. I'm just not able to come up with a solution that preserves all of the data and keeps it all in its own cell. Any help is greatly appreciated.