Skip to content

Sum by categorical variable

3 messages · De Amicis Fabrizio (G.I.T.), Mahmood ARAI, vito muggeo

#
Dear R-list,
I have two variables (numerical and categorical) and  would like to have the
sum (and maybe some other statistics) of the numerical variable by the
categorical one. 
Can you help me,
Thank you,
Fabrizio


---------------------------------------------------------------
Fabrizio De Amicis

IT Department
Generali Information Technologies - (GIT)

Centro Galleria 2,
Via Cantonale
CH - 6928 Manno - Switzerland
Tel  +41 91 806 6220
Fax +41 91 806 6298
E-mail: fabrizio.deamicis at git.generali.ch  




************************************************************************
The information in this email is confidential and may be legally... {{dropped}}
#
De Amicis Fabrizio (G.I.T.) writes:
ave is what your are looking for.
See ?ave. 

mahmood arai 

http://www.ne.su.se/~ma
#
If I understand correctly what you are looking for, see ?tapply.
Below there is a toy example
CategVar
 0  1
33 67
0        1
15.17833 32.11759

sum can be replaced by any function including mean, median, and
user-defined.
best,
vito


----- Original Message -----
From: "De Amicis Fabrizio (G.I.T.)" <Fabrizio.DeAmicis at git.generali.ch>
To: "'r-help at lists.R-project.org'" <r-help at stat.math.ethz.ch>
Sent: Tuesday, May 06, 2003 4:08 PM
Subject: [R] Sum by categorical variable
the
{{dropped}}