我需要从
更改R中的data.frameSample Protein Value
a TBA 10
b TBA 5
a TBB 30
b TBB 20
对此
Protein a b
TBA 10 5
TBB 30 20
我该怎么做?感谢您的帮助!
答案 0 :(得分:1)
尝试dcast
中的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)
输出:
Protein a b
1 TBA 10 5
2 TBB 30 20
答案 1 :(得分:0)
一个选项是
library(tidyr)
spread(df1, Sample, Value)