Hi,
On 12/15/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
You don't get them as a column but you get them as the
component labels.
by(df, df$Day, function(x) colMeans(x[,-1]))
If you convert it to a data frame you get them as the rownames:
do.call(rbind, by(df, df$Day, function(x)
On 12/16/05, January Weiner [EMAIL PROTECTED] wrote:
Hi,
On 12/15/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
You don't get them as a column but you get them as the
component labels.
by(df, df$Day, function(x) colMeans(x[,-1]))
If you convert it to a data frame you get them
Gabor Grothendieck wrote:
On 12/16/05, January Weiner [EMAIL PROTECTED] wrote:
Hi,
On 12/15/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
You don't get them as a column but you get them as the
component labels.
by(df, df$Day, function(x) colMeans(x[,-1]))
If you convert it to a data
One other point. The cor example could be done using tapply like
this:
tapply(rownames(df), df$Day, function(r) cor(df[r,val1], df[r, val2]))
On 12/16/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
On 12/16/05, January Weiner [EMAIL PROTECTED] wrote:
Hi,
On 12/15/05, Gabor Grothendieck
Hello again,
On 12/14/05, Thomas Lumley [EMAIL PROTECTED] wrote:
You want
by(df[,-1], df$Day, function.that.means.each.column)
OK, slowly :-) I don't understand it.
- why df[,-1] and not df? don't we loose the df$Day entries?
(by the way, why does typeof(df) show list? I thought that
On 12/15/05, January Weiner [EMAIL PROTECTED] wrote:
Hello again,
On 12/14/05, Thomas Lumley [EMAIL PROTECTED] wrote:
You want
by(df[,-1], df$Day, function.that.means.each.column)
OK, slowly :-) I don't understand it.
- why df[,-1] and not df? don't we loose the df$Day entries?
You
Hi,
I read about the by() function, but it does not seem to do the job I
need. Here is the problem:
Say - I have a data frame, with three columns. The first one contains
strings that describe the data points, with repeats (for example, days
of a week). The other two contain numbers. Something
On Wed, 14 Dec 2005, January Weiner wrote:
Hi,
I read about the by() function, but it does not seem to do the job I
need. Here is the problem:
by() will work, you just need to use the right function in it.
You want
by(df[,-1], df$Day, function.that.means.each.column)
so all you need to do