[R] aggregate?

alex diaz celebridades at megamail.pt
Sat Jun 18 01:56:35 CEST 2005


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

A. Diaz



-------------------------------------------------
Email Enviado utilizando o serviço MegaMail




More information about the R-help mailing list