Learn R Programming

epiR (version 2.0.68)

epi.descriptives: Descriptive statistics

Description

Computes descriptive statistics for a numeric vector or a table of frequencies for a factor.

Usage

epi.descriptives(dat, conf.level = 0.95)

Value

If dat is numeric a list containing the following:

arithmetic

n number of observations, mean arithmetic mean, sd arithmetic standard deviation, q25 25th quantile, q50 50th quantile, q75 75th quantile, lower lower bound of the confidence interval, upper upper bound of the confidence interval, min minimum value, max maximum value, and na number of missing values.

geometric

n number of observations, mean geometric mean, sd geometric standard deviation, q25 25th quantile, q50 50th quantile, q75 75th quantile, lower lower bound of the confidence interval, upper upper bound of the confidence interval, min minimum value, max maximum value, and na number of missing values.

symmetry

skewness and kurtosis.

If dat is a factor a data frame listing:

level

The levels of the factor

n

The frequency of the respective factor level, including the column totals.

Arguments

dat

either a numeric vector or a factor.

conf.level

magnitude of the returned confidence intervals. Must be a single number between 0 and 1.

Examples

Run this code
## EXAMPLE 1:
## Generate some data:
id <- 1:100
n <- rnorm(100, mean = 0, sd = 1)
dat.df01 <- data.frame(id, n)

# Add missing values:
missing <- dat.df01$id %in% sample(dat.df01$id, size = 20)
dat.df01$n[missing] <- NA

epi.descriptives(dat.df01$n, conf.level = 0.95)


## EXAMPLE 2:
## Generate some data:
n <- 1000; p.exp <- 0.50; p.dis <- 0.75
strata <- c(rep("A", times = n / 2), rep("B", times = n / 2))
exp <- rbinom(n = n, size = 1, prob = p.exp)
dis <- rbinom(n = n, size = 1, prob = p.dis)
dat.df02 <- data.frame(strata, exp, dis)

dat.df02$strata <- factor(dat.df02$strata)
dat.df02$exp <- factor(dat.df02$exp, levels = c("1", "0"))
head(dat.df02)

epi.descriptives(dat.df02$exp, conf.level = 0.95)

Run the code above in your browser using DataLab