Re: [R] by output into data frame

2012-03-19 Thread Peter Meilstrup
Thanks for providing a reproducible example. Using the plyr package you can write your whole computation more compactly: library(plyr) library(caTools) #for trapz auc <- ddply(lab.samples, .(challenge, subid), function(df) { df$time <- c(0, seq(60,by=10, len=nrow(df)-1)) summari

Re: [R] by output into data frame

2012-03-19 Thread Peter Ehlers
On 2012-03-19 15:00, Jorge I Velez wrote: Hi David, Thank you for the reproducible example! Try do.call(rbind, auc_stress) cortisol amylase 2 919.05 6834.80 3 728.25 24422.05 4 2106.00 25908.35 6 636.40 12209.75 7 1925.95 4749.25 do.call(rbind, auc_control) cortisol amyl

Re: [R] by output into data frame

2012-03-19 Thread Jorge I Velez
Hi David, Thank you for the reproducible example! Try > do.call(rbind, auc_stress) cortisol amylase 2 919.05 6834.80 3 728.25 24422.05 4 2106.00 25908.35 6 636.40 12209.75 7 1925.95 4749.25 > do.call(rbind, auc_control) cortisol amylase 2 604.90 2458.00 4 587.65 29954.55 6

[R] by output into data frame

2012-03-19 Thread David Perlman
I could do this in various hacky ways, but what's the right way? I have a nice application of the by function, which does what I want. The output looks like this: > auc_stress lab.samples.stress$subid: 2 cortisol amylase 1 919.05 6834.8 -