R/tableNoteR.R

Defines functions tablenoteR

Documented in tablenoteR

#' Table Noter
#'
#' @param analysis Analysis that produced data for regression analyses: "cfa", "bf", or "lca"
#' @param model Name of model, i.e., set of predictors
#' @param outcomeVar Name of outcome variable
#' @param outcomesWithExtraNote Vector of names of outcomes that need extra table note
#' @param modelsWithExtraNote Vector of names of predictor models that need extra table note
#'
#' @return LaTeX syntax for table note
#' @export
tablenoteR <- function(analysis, model, outcomeVar, outcomesWithExtraNote = NULL, modelsWithExtraNote = NULL) {

  tableNote <- NULL

  if (analysis == 'cfa') tableNote <- paste0(tableNote, 'CFA = Confirmatory Factor Analysis. ')
  if (analysis == 'bcfa') tableNote <- paste0(tableNote, 'BCFA = Bayesian Confirmatory Factor Analysis. ')
  if (analysis == 'bf') tableNote <- paste0(tableNote, 'BF = Bifactor Analysis. ')
  if (analysis == 'lca' | analysis == 'LCA') tableNote <- paste0(tableNote, 'LCA = Latent Class Analysis. ')

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

##### Place to put rules to add notes for certain groups of outcomes or models ####

  if (outcomeVar %in% outcomesWithExtraNote == TRUE) { # if outcome in subset of outcomes in outcomesWithExtraNote argument
    tableNote <- paste0(tableNote, 'SF-12 = Short Form Health Survey. ') # add note defining acronymn
  }
  if (model %in% modelsWithExtraNote) { # if outcome in subset of models in modelWithExtraNote argument
    tableNote <- paste0(tableNote, 'DSM-5 = Diagnostic and Statistical Manual, 5th Edition. ') # add note for model acronym
  }

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

  return(tableNote)

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