View source: R/epi.descriptives.R
epi.descriptives | R Documentation |
Computes descriptive statistics for a numeric vector or a table of frequencies for a factor.
epi.descriptives(dat, conf.level = 0.95)
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. |
If dat
is numeric a list containing the following:
arithmetic |
|
geometric |
|
symmetry |
|
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. |
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.