Learn R Programming

Deducer (version 0.7-9)

descriptive.table: Table of Descriptives

Description

Table of descriptive statistics, possibly stratified

Usage

descriptive.table(vars, strata, data, func.names = c("Mean","St. Deviation","Median", "25th Percentile","75th Percentile", "Minimum","Maximum","Skew","Kurtosis","Valid N"), func.additional)

Arguments

vars
A variable or data.frame containing variables on which to run descriptive statistics.
data
The data frame in which vars is evaluated
strata
A variable or data.frame containing variables on which to stratify
func.names
A character vector of built-in statistics
func.additional
A named list of functions. Each function should take a numeric vector as its argument, and return a single value

Value

Returns a list of matrix objects containing descriptive information on all variables in dat. One for each level or combination of levels in strata.

See Also

frequencies mean by

Examples

Run this code
data(mtcars)
##means and standard deviations
descriptive.table(vars = d(mpg,hp),data= mtcars,
	func.names =c("Mean","St. Deviation","Valid N"))
##stratifying by cyl
descriptive.table(vars = d(mpg,hp) ,
	strata = d(cyl),data= mtcars,
	func.names =c("Mean","St. Deviation","Valid N"))
	
	
func.list=list(mean.deviance=function(x) mean(abs(x-mean(x))))

##Adding deviance as a statistic
descriptive.table(vars = d(mpg,hp) ,
	strata = d(cyl),data= mtcars,
	func.names =c("Mean","St. Deviation","Valid N"),func.additional=func.list)

Run the code above in your browser using DataLab