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")
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.