[R] aggregate without removing empty subset
Christophe Genolini
cgenolin at u-paris10.fr
Mon Mar 15 18:10:15 CET 2010
Hi the list,
As it is say in its doc, the aggregate function remove empty subsets. Is
it possible to NOT remove empty subset ?
--- 8< -------
m <- matrix(1:12,4)
part <- factor(c("A","B","A","B"),levels=c("A","B","C"))
aggregate(m,list(part),mean)
### I get:
# Group.1 V1 V2 V3
# 1 A 2 6 10
# 2 B 3 7 11
#
### I would like:
# Group.1 V1 V2 V3
# 1 A 2 6 10
# 2 B 3 7 11
# 3 C NA NA NA
--- 8< ------
Thanks
Christophe
More information about the R-help
mailing list