Hi S-users,
if we merge the levels of one, or more, factors in a data.frame the resulting
data.frame will have several identical factor combinations. Is it possible to
aggregate (summing is good enough in my case) the cells corresponding to
identical factor combinations. For exemple take the builtin dataset "claims",
claims has three factors and two continuous variables. Suppose I want to merge
levels "17-20" with "21-24" and "30-34" with "35-39" of factor age, and I also
want to merge levels "A" with "B" and "C" with "D" of factor type. While, or
after, doing so I would like to have the continuous variables "cost" and
"number" summed for identical factor combinations which means that the dataset
will shrink row wise? Can this be done efficiently? I know that merge.levels
will merge factor levels but that is all it will do? A solution involving the
builtin function "aggregate" will not work for me, the datasets are too big.
Thanks for any hints,
Gérald Jean
Analyste-conseil (statistiques), Actuariat
télephone : (418) 835-8839
télecopieur : (418) 835-5865
courrier électronique: gerald.jean@spgdag.ca
"In God we trust all others must bring data"
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|