R/titleR.R

Defines functions titleR

Documented in titleR

#' LaTeX Table Title Maker
#'
#' @param analysis Analysis that produced data for regression analyses: "cfa", "bf", or "lca"
#' @param model Which model (numerically) out of the list of models? Pulls predictors from modelPredictorNamesList
#' @param outcomeVar Outcome variable name
#'
#' @return
#' @export
titleR <- function(analysis, model, outcomeVar) {

  require(Hmisc)

  modelName <- Hmisc::capitalize(model)

# ------------------------------------------------- #
# ------------------------------------------------- #

##### Place to put rules for changing model names (other than capitalization) ####

  if (model == 'dysphoricarousal') {
    modelName <- gsub(model, pattern = 'dysphoricarousal', replacement = 'Dysphoric Arousal')
  }

# ------------------------------------------------- #
# ------------------------------------------------- #

  outcomeName <- outcomeNameVector[outcomeVar]

  if (analysis == 'bcfa') caption <- paste0('Summary of Analyses with ', outcomeName, ' and the ', modelName, ' BCFA Model', '.')
  if (analysis == 'cfa') caption <- paste0('Summary of Analyses with ', outcomeName, ' and the ', modelName, ' CFA Model', '.')
  if (analysis == 'bf') caption <- paste0('Summary of Analyses with ', outcomeName, ' and the ', modelName, ' Bifactor Model', '.')

  if (grepl(pattern = 'lca', x = analysis) == TRUE) {
    classes <- gsub(pattern = 'lca', x = analysis, replacement = '')
    caption <- paste0('Summary of Analyses with ', outcomeName, ' and the ', classes, '-Class LCA', '.')
  }

  return(caption)

}
enaY15/TabulationAutomation documentation built on March 18, 2020, 8:35 p.m.