I have a data.frame from this code:
my_df = data.frame(\"read_time\" = c(\"2010-02-15\", \"2010-02-15\",
\"2010-02-
The plyr package is popular for this, but the base functions by()
and aggregate()
will also help.
> ddply(my_df, "read_time", function(X) data.frame(OD=mean(X$OD),stdev=sd(X$OD)))
read_time OD stdev
1 2010-02-15 0.15000 0.07071
2 2010-02-16 0.23333 0.15275
3 2010-02-17 0.50000 NA
You can add the missing bit to return 0 instead of NA for the last std.dev.
Also, you don't need the quotes (on the variables) you had in the data.frame construction.