I need to transform some data like this:
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")
What I want to end up with is this:
1 2 3 4
A 1 10 100 1000
B 1 10 100 NA
C 1 10 100 1000
Is there a way to fill the missing B4
row with NA
or just ignore it? The t
function or ddply
seem to be choking on the fact that B
is a different length than the others.
Thanks, J--