#' Build Header for LaTeX Table
#'
#' @param caption Caption produced by internal function titleR
#' @param mat Name of result summary matrix to look for in environment...Format: <outcome>_<analysis>_<model>
#' @param outcomeVar Outcome variable name
#' @param analysis Analysis that produced data for regression analyses: "cfa", "bf", or "lca"
#' @param stats Vector of types of statistics in table, e.g., c('Estimate', 'Pr(>|t|)')
#'
#' @return
#' @export
headerBuildeR <- function(caption, mat, outcomeVar = NULL, analysis, stats) {
if (is.null(outcomeVar)) {
outcomeVar <- deparse(substitute(mat)) # name of matrix
outcomeVar <- sub(pattern = '_.*', x = outcomeVar, replacement = '') # erase '_' and following characters in name of matrix
}
# ------------------------------------------------------------------ #
# ------------------------------------------------------------------ #
##### Place to customize label system for LaTeX table referencing ####
label <- paste0(analysis, '_', outcomeVar)
# ------------------------------------------------------------------ #
# ------------------------------------------------------------------ #
syntax <- paste0('
\\begin{table}
\\begin{threeparttable}
\\renewcommand\\TPTminimum{\\textwidth}
\\centering
\\caption{', caption, '}
\\label{tab:', label, '}', '
\\begin{tabular}{')
syntax <- c(syntax, as.character(paste0(rep('l', (length(stats) + 1)))), '} \\toprule
')
header <- syntax
rm(syntax)
cat(header)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.