I have a data frame like that:
HLA_Status variable value
1 PP CCL24 9.645
2 PP CCL24 56.32
3 PP CCL24 7.268
4 PC CCL24 5.698
5 PC CCL24 89.457
6 PC CCL24 78.23
7 PP SPP1 23.12
8 PP SPP1 36.32
9 PP SPP1 17.268
10 PC SPP1 2.698
11 PC SPP1 9.457
12 PC SPP1 8.23
I want to reshape my data frame with reshape2::dcast() and get this:
HLA_Status CCL24 SPP1
1 PP 9.645 23.12
2 PP 56.32 36.32
3 PP 7.268 17.268
13 PC 5.698 2.698
14 PC 89.457 9.457
15 PC 78.230 8.23
But I didn't manage to do this.
I tried this:
dcast(mydt, HLA_Status ~ variable, value.var = "value")
But it didn't work.
And I see on the documentation of reshape2 that if we have multiple values per cell we need to tell dcast how to aggregate the data.
I think my problem is to don't know what to give to fun.aggregate.
How can I get the wanted data frame by using reshape2 or others packages?