# UNITABLE ---------------------------
#' Create a table of frequencies, relative frequencies, and odds for a single variable
#'
#' @param data A data frame
#' @param variable A variable without quotes
#' @examples
#' library(carData)
#' uniTable(data = carData::Arrests, variable = employed)
#' @export
uniTable <- function(data, variable) {
variable <- dplyr::enquo(variable)
data %>% dplyr::group_by(!!variable) %>%
dplyr::summarise(Frequency = dplyr::n()) %>%
dplyr::mutate(Proportion = Frequency / sum(Frequency),
Odds = Frequency / (sum(Frequency) - Frequency))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.