R/kable2.R

Defines functions kable2

Documented in kable2

#' Knit table and round decimal places
#'
#' Wrapper function to quickly knit a table and round numeric values.
#'
#' @param df Dataframe you want to knit.
#' @param digits Number of decimal places, trailing zeros removed.
#'
#' @return Markdown table
#' @export
#'
#' @examples
#' kable2(mtcars)
#'
kable2 <- function(df, digits = 2) {
  knitr::kable(dplyr::mutate_if(df, is.numeric, round, digits))
}
bsurial/bernr documentation built on Nov. 7, 2022, 1:41 a.m.