Re: [R] percent by subset

2010-05-02 Thread David Freedman
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

Re: [R] percent by subset

2010-05-02 Thread David Winsemius
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,

Re: [R] percent by subset

2010-05-02 Thread Henrique Dallazuanna
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,

[R] percent by subset

2010-05-02 Thread Geoffrey Smith
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,