how about:
d=data.frame(ht=rnorm(20,60,20),sex=sample(0:1,20,rep=T)); d
with(d,by(ht,sex,mean))
with(d,by(ht,sex,function(x)mean(x>=60)))
hth, david freedman
--
View this message in context:
http://r.789695.n4.nabble.com/percent-by-subset-tp2123057p2123079.html
Sent from the R help mailing lis
On May 2, 2010, at 1:58 PM, Geoffrey Smith wrote:
Suppose my data looks like this:
Obs, Male, Female, Height
1, T, F, 66
2, F, T, 64
3, T, F, 59
4, T, F,
Try this:
prop.table(table(subset(x, Height > 60, select = Male:Female)))
On Sun, May 2, 2010 at 2:58 PM, Geoffrey Smith wrote:
> Suppose my data looks like this:
>
> Obs, Male, Female, Height
> 1, T, F, 66
> 2, F, T,
Suppose my data looks like this:
Obs, Male, Female, Height
1, T, F, 66
2, F, T, 64
3, T, F, 59
4, T, F, 55
5, F, T, 62
6,
4 matches
Mail list logo