percent {memisc} | R Documentation |
percent
returns a table of percentages along with
the percentage base. It will be useful
in conjunction with aggregate.formula.
percent(x,weights=NULL)
x |
a numeric vector or factor. |
weights |
a numeric vector of weights of the same length as x . |
A character vector of formatted numbers.
ex.data <- expand.grid(mean=c(0,25,50),sd=c(1,10,100))[rep(1:9,rep(250,9)),] ex.data <- transform(ex.data,x=rnorm(n=nrow(ex.data),mean=ex.data$mean,sd=ex.data$sd)) ex.data <- transform(ex.data,x.grp = cases( x < 0, x >= 0 & x < 50, x >= 50 & x < 100, x >= 100 )) genTable(percent(x.grp)~mean+sd,data=ex.data) aggregate(percent(Admit,weight=Freq)~Gender+Dept,data=UCBAdmissions)