View source: R/epi_functions.R
expand_df | R Documentation |
expand_df
expands a data frame by a vector of frequencies.
expand_df(aggregate.data, index.var = "Freq", retain.freq = FALSE)
aggregate.data |
A data frame. |
index.var |
A numerical variable with the frequencies (counts). |
retain.freq |
Logical expression indicating if frequencies should be kept. |
This is a generic function that resembles weighted frequencies in other statistical packages
(for example, Stata). expand.df
was adapted from a function developed by deprecated package
epicalc
(now package epiDisplay
).
An expanded data frame with replicates given by the frequencies.
Freq <- c(5032, 5095, 41, 204)
Mortality <- gl(2, 2, labels = c("No", "Yes"))
Calcium <- gl(2, 1, 4, labels = c("No", "Yes"))
anyca <- data.frame(Freq, Mortality, Calcium)
anyca
anyca.exp <- expand_df(anyca)
with(anyca.exp, table(Calcium, Mortality))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.