[R] aggregate?

From: alex diaz <celebridades_at_megamail.pt>
Date: Sat 18 Jun 2005 - 09:56:35 EST


Dear all:

Here is my problem:

Example data:
dat<-data.frame(x=rep(c("a","b","c","d"),2),y=c(10:17))

If I wanted to aggregate each level of column dat$x I could use:
aggregate(dat$y,list(x=dat$x),sum)

But I just want to aggregate two levels (“c” and “d”) to obtain a new level “e”
I am expecting something like:

  x y
1 a 10
2 b 11
3 e 25
4 a 14
5 b 15
6 e 33

How can I make it?
Thanks in advance and best for all

  1. Diaz

Email Enviado utilizando o serviço MegaMail



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jun 18 09:59:29 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:50 EST