Matthew Walker <m.g.walker <at> massey.ac.nz> writes:
 
: I have a data frame that contains a number of pass/fails for certain 
: variable sizes.  From that, I would like to form another data frame that 
: contains the proportions of pass/fails per variable.
: 
: So, for example:
: df <- data.frame( Var=c(3,3,3,4,4), 
: Result=c("pass","fail","fail","pass","pass"), SampleSize=c(3,3,3,2,2))
: 
: And I'd like to produce the equivalent of:
: data.frame( Var=c(3,4), ProportionPass=c(0.33, 1) )


Try using aggregate like this:

 aggregate( data.frame(ProportionPass = as.numeric(df$Result)-1), 
      list(Var = df$Var), mean)

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to