Re: [R] adding aggregate data to data frames

2007-10-19 Thread jim holtman
Does this do what you want? > x <- data.frame(subj=sample(1:3,20,TRUE), cond=sample(1:2,20,TRUE), > time=runif(20,1,10)) > # add mean and sd > x$mean <- ave(x$time, x$subj, x$cond) > x$sd <- ave(x$time, x$subj, x$cond, FUN=sd) > x subj cond time mean sd 1 32 3.563114 5.63

Re: [R] adding aggregate data to data frames

2007-10-19 Thread John Kane
I have been trying to figure out how Hadley Wickhams "reshape" package works and I tried it on what may be your problem. Here is my example. Does it do something like what you want? === # Test Data zz <- "subj cond t1 t2 t3 A1 4 5 7 A