R/kablify.R

Defines functions kablify

Documented in kablify

#' Build a kable from a table, change proportions to
#' percentages
#'
#' @param tab
#'
#' @return
#' @export
#'
#' @examples
kablify <- function(tab) {

  tab %>%
    mutate_if(
      function(x) ifelse(is.factor(x), FALSE, is.numeric(x) & max(x) <= 1 & min(x) >= 0),
      scales::percent
    ) %>%
    knitr::kable(digits = 3)



}
blueprint-ade/bputils documentation built on May 29, 2019, 5:57 p.m.