I need to change a data.frame in R from this
Sample Protein Value
a TBA 10
b TBA 5
a TBB 30
b TBB 20
to this
Protein a b
TBA 10 5
TBB 30 20
How do I do this? Thanks for the help!
I need to change a data.frame in R from this
Sample Protein Value
a TBA 10
b TBA 5
a TBB 30
b TBB 20
to this
Protein a b
TBA 10 5
TBB 30 20
How do I do this? Thanks for the help!
Try dcast
from reshape2
:
df <- data.table::fread('Sample Protein Value
a TBA 10
b TBA 5
a TBB 30
b TBB 20')
dcast(df, formula = Protein ~ Sample)
Output:
Protein a b
1 TBA 10 5
2 TBB 30 20