Learn R Programming

lazyWeave (version 2.2.0)

univ: Univariate Table

Description

Similar to the QHS SAS macro, provides a numerical simple summary of numerical variables.

Usage

univ(data, vars, byVar, alpha=0.05)

Arguments

data
A ccf.df or data.frame containing the variables in vars and byVar.
vars
Character vector naming the variables in data to be summarized.
byVar
A categorical variables giving groups by which statistics should be computed.
alpha
significance level for determining the confidence limits.

code

conttable

Details

Statistics available in univ, and the calls to get them are:
  1. n
{number of non-missing values.} missing{number of missing values} mean{arithmetic mean} median{median value} sd{standard deviation} lcl{lower confidence limit} ucl{upper confidence limit} min{minimum value} max{maximum value} p25{25th percentile} p75{75th percentile} cv{coefficient of variation}

See Also

write.univ

Examples

Run this code
#Read in the delivery dataset from the CCFmisc library
require(Hmisc)

data(Delivery)

#use Hmisc library to labeling variables in univariate tables
label(Delivery$maternal.age) <- "Maternal Age"
label(Delivery$ga.weeks) <- "Gestation weeks"
label(Delivery$wt.gram) <- "Weight (g)"


#a univariate table of the variables maternal age,
#ga.weeks and wt.grams.  The object resulting
#from univ() can be used in other functions to create html or
#LaTeX tables.

uni <- univ(Delivery,
            vars=c("maternal.age", "ga.weeks", "wt.gram"))

#a univariate table of the variables maternal age,
#ga.weeks and wt.grams by delivery.type.  The object resulting
#from univ() can be used in other functions to create html or
#LaTeX tables.

deliv.uni <- univ(Delivery,
	vars=c("maternal.age", "ga.weeks", "wt.gram"),
	byVar="delivery.type")

#if you want to take advantage of the confidence interval
#output from univ() different alpha levels can be set
#by the alpha= argument.

deliv_99.uni <- univ(Delivery,
	vars=c("maternal.age", "ga.weeks", "wt.gram"),
	byVar="delivery.type",
	alpha=0.01)

Run the code above in your browser using DataLab