This may be a newbie question, but I've searched everywhere and can't find a way to do it. I have a data frame in R that looks like this:
Target Sample Regulation
AKT1 00h 1.00000
AKT1 02h 1.27568
AKT1 06h -1.29813
AKT1 12h 1.12357
AKT1 48h 1.02284
AKT2 00h 1.00000
AKT2 02h 1.08692
AKT2 06h 1.19489
AKT2 12h -1.07677
AKT2 48h -1.18955
data$Target and data$Sample are class=factor
I need to create a table to look like this:
Target/Sample AKT1 AKT2
00h 1.00000 1.00000
02h 1.27568 1.08692
06h -1.29813 1.19489
12h 1.12357 -1.07677
48h 1.02284 -1.18955
In other words, I need to create a new data frame where the columns are data$Target levels, the rows are data$Sample levels, and populate it with the corresponding values in data$Regulation.
This is what I could come up with:
newdata <- data.frame(Time=levels(data$Sample),
AKT1=as.numeric(data$Regulation[which(dat$Target=="AKT1",)]))
but of course I don't want to go one by one since dat$Target has >100 levels (genes). Help please!
Thank you all so much!