desc_vars: Describe Variables

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/ares.r

Description

Compute some common descriptives statistics of variables

Usage

1
2
3
desc_vars(vars, by = NULL, stats = c("n", "na", "mean", "sd", 
	"min", "max", "centiles"), probs = c(0.25, 0.5, 0.75), 
	labels = NULL, print = TRUE, digits = getOption("digits"), ...)

Arguments

vars

a vector of quoted strings with the variables names or a formula, e.g. ~x+y

by

a factor variable for subset analysis.It will be coerced to a factor. Default is NULL

stats

a vector of quoted strings with the statistics to be computed. See Details

probs

a vector of probabilities for the quantiles computation

labels

a vector of quoted strings with alternate labels for the variables. If omitted vars is used

print

a logical indicating whether the statistics should be printed

digits

an integer indicating the number of decimal places to print. Default is given by the system option digits

...

further arguments for mean, basically, support for trimming

Details

By default, this function computes the following statistics: n: number of observations, na: number of missing values, mean: variable means, sd: standard deviation, min: minimum value; max: maximum value, and centiles: quantiles controlled by the vector probs. Any subset of these statistics can be selected. However, if other than these is indicated it will throw an error. The statistics in stats are not case sensitive.

If the argument by is set, the statistics are computed for each subset defined by the supplied vector.

These statistics are frequently found on publications regarding air pollution and health effects.

Value

The function invisibly returns a data frame with a variable per line and a statistic per column.

Author(s)

Washington Junger wjunger@ims.uerj.br and Antonio Ponce de Leon ponce@ims.uerj.br

References

Schwartz, J., Spix, C., Touloumi, G. et al. (1996) Methodological issues in studies of air pollution and daily counts of deaths or hospital admissions. J Epidemiol. Community Health 50 (suppl 1), S12–S18.

Whetherill, G. B. Elementary Statistical Methods. 2 ed. Chapman and Hall.

See Also

summary,mean,quantile

Examples

1
2
3
4
5
6
7
data(admrio)
setup(admrio,"date")
## no stratified analysis
d <- desc_vars(~resp5+pm10+so2+co,stats=c("n","mean","sd","centiles"),digits=3)
## stratified analysis
d <- desc_vars(~resp5+pm10+so2+co,by=quarters,stats=c("n","mean","sd","centiles"),
	digits=3)

wjunger/ares documentation built on Dec. 23, 2021, 5:17 p.m.