#' @title add_title
#' @description Function to add title to tableGrob.
#'
#' @param tgrob tableGrob
#' @param title Title to add
#' @param flex Boolean indicating if table is for rmarkdown flexdashboard.
#' Defaults to FALSE
#'
#' @return Returns tableGrob with title added.
#' @export
add_title <- function(tgrob, title, flex = FALSE) {
fontsize <- ifelse(flex, 8, 12)
title <- textGrob(title, gp = gpar(fontsize = fontsize))
padding <- unit(5, 'mm')
tgrob <- gtable::gtable_add_rows(tgrob,
heights = grobHeight(title) + padding,
pos = 0)
tgrob <- gtable::gtable_add_grob(tgrob, title, t = 1, l = 1, r = ncol(tgrob))
return(tgrob)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.