percent {memisc}R Documentation

Table of Percentages with Percentage Base

Description

percent returns a table of percentages along with the percentage base. It will be useful in conjunction with aggregate.formula.

Usage

  percent(x,weights=NULL)

Arguments

x a numeric vector or factor.
weights a numeric vector of weights of the same length as x.

Value

A character vector of formatted numbers.

Examples

  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)

[Package memisc version 0.11-8-2 Index]