#' @title Create dummy variables.
#'
#' @description \code{dummy_vars} Create dummy variables.
#'
#' @details Function to create dummy variables
#'
#' @param \code{x} dataframe over which to cerate dummy variables.
#'
#' @return Cleaned vector or integers of age in days.
#'
#' @import dummies
#' @examples
#'
dummy_vars <- function(x, variable){
x_levels <- sort(unique(x[[variable]]))
x1 <- x %>%
dplyr::select_(variable) %>%
as.data.frame %>%
dummies::dummy.data.frame %>%
magrittr::set_colnames(x_levels)
return(x1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.