Re: [R] transforming data based on factors in a dataframe

2012-04-25 Thread David Winsemius
On Apr 25, 2012, at 10:57 AM, Carly Huitema wrote: Hello R-help list, I would really appreciate help with my factoring problem. My generated data is this: df <- expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2)) df$curve <- as.factor(rep(1:6, each=length(seq(10,80, by=5 df$count

Re: [R] transforming data based on factors in a dataframe

2012-04-25 Thread jim holtman
try this: (uses 'ave') > df <- expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2)) > df$curve <- as.factor(rep(1:6, each=length(seq(10,80, by=5 > df$counts <- 3*df$T/df$conc + rnorm(df$T,0,2) > > plot(counts~T, df) > df$zero <- ave(df$counts, df$curve, FUN = function(x) x - min(x)) > > d

[R] transforming data based on factors in a dataframe

2012-04-25 Thread Carly Huitema
Hello R-help list, I would really appreciate help with my factoring problem. My generated data is this: df <- expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2)) df$curve <- as.factor(rep(1:6, each=length(seq(10,80, by=5 df$counts <- 3*df$T/df$conc + rnorm(df$T,0,2) plot(counts~T, df)