R/add_totals.R

Defines functions add_totals

Documented in add_totals

#' Add subscale scores
#' @export
#' @importFrom psych scoreItems
#'
add_totals <- function(data, keys) {
  my.scales.3 <- scoreItems(keys, data, totals = TRUE)
  my.scores.3 <- my.scales.3$scores
  # Add scale scores to data frame
  data$risk <- my.scores.3[, 1]
  data$cardioresp <- my.scores.3[, 2]
  data$airway <- my.scores.3[, 3]
  data$ncmscs_total <- my.scores.3[, 4]
  return(data)
}
awconway/nc-mscs documentation built on Feb. 17, 2021, 10:07 p.m.