Hi again!
Please try something like this:
> zone1.df
zone sex len
1 1 male 15
2 1 fema 20
3 1 fema 17
4 2 fema 19
5 2 male 18> str(zone1.df)
'data.frame': 5 obs. of 3 variables:
$ zone: Factor w/ 2 levels "1","2": 1 1 1 2 2
$ sex : Factor w/ 2 levels "fema","male": 2 1 1 1 2
$ len : int 15 20 17 19 18> tapply(zone1.df$len,zone1.df[,-3],mean)
sex
zone fema male
1 18.5 15
2 19.0 18>
Hope this helps!
Sincerely,
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: hodgess at gator.uhd.edu
From: "Jorge Cornejo-Donoso" <jorgecornejo at uach.cl>
To: "'Erin Hodgess'" <hodgess at gator.dt.uh.edu>
Subject: RE: [R] RV: by sentence
OK.. Thank for the advice.
By and tapply works with 1 categorical variable, but what can be
used for 2 categorical variables. Example:
Zone Sex Length
1 male 15
1 fema 20
1 fema 17
2 fema 19
2 male 18
The idea is to get the means by sex in each zone!
Thank in advance!
--
Jorge Cornejo Donoso
Universidad Austral de Chile
______________________________________________
R-help at 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
and provide commented, minimal, self-contained, reproducible code.