plyr - Normalize data by use of ratios based on a changing dataset in R -
i trying normalize y scale converting values percentages. therefore, need divide every number in column first number in column. in excel, equivalent locking cell a1/$a1, b1/$a1, c1/$a1 d1/$d1, e1/$d1...
the data needs first meet 4 criteria (time, treatment, concentration , type) , reference value changes @ every new treatment. each treatment has 4 concentrations (0, 0.1, 2 , 50). values associated each concentration divided reference value (when concentration equal 0).
the tricky part reference value changes every 4 rows.
i have tried doing using ddply:
`mastertable <- read.csv("~/dropbox/master-table.csv")` mastertable <- ddply(mastertable, .(time, type, treatment), transform, pc=(value/value$concentration==0))
but not working @ all. appreciated!
my data file can found here: master-table
thank you!
dplyr
efficient here:
library(dplyr) result <- group_by(mastertable, time, type, treatment) %>% mutate(pc = value / value[1])
Comments
Post a Comment