我需要变换一些像这样的数据:
df<-data.frame(Plate=c("4660", "4660", "4660", "4660", "4660", "4660", "4660", "4660", "4660", "4660", "4660"), Well=c("A1", "A2", "A3", "A4", "B1", "B2", "B3", "C1", "C2", "C3", "C4"), Result=c(1, 10, 100, 1000, 1, 10, 100, 1, 10, 100, 1000), Compound=c("C1", "C1", "C1", "C1", "C2", "C2", "C2", "C3", "C3", "C3", "C3"))
cmpds <- ddply(df, .(Compound), .fun = "t")
我想最终得到的是这个:
1 2 3 4
A 1 10 100 1000
B 1 10 100 NA
C 1 10 100 1000
有办法用 < code> > NA < /code > 填充缺失的 < code > B4 < /code > 行还是忽略它? < code> t < /code > 函数或 < code> ddply 似乎窒息了,因为 < code > B < /code > 的长度与其他的长度不同。
Thanks, J--