R/kable_scroll.R

Defines functions kable_scroll

kable_scroll <- function(table, width, height) {
  # Make a scrollable HTML table of specified dimensions.
  # 
  # Arguments:
  #   table {dataframe} -- dataframe to display
  #   width {numeric} -- width of kable in pixels
  #   height {numeric} -- height of kable in pixels
  #
  # Function Dependencies:
  #   - knitr
  #
  # Returns:
  #   {knitr::kable}
  
  library(knitr)

  stopifnot(is.data.frame(table))
  stopifnot(is.numeric(width))
  stopifnot(is.numeric(height))

  knitr::kable(
    table,
    "html"
  ) %>%
    kable_styling(
      full_width = FALSE
    ) %>%
    scroll_box(
      width = paste0(width, "px"),
      height = paste0(height, "px")
    )
}
tsouchlarakis/rdoni documentation built on Sept. 16, 2019, 8:53 p.m.