R/combineWeightsAndNorms.R

Defines functions combineWeightsAndNorms

Documented in combineWeightsAndNorms

#' combineWeightsAndNorms
#'
#' This function takes the normalised indicator scores and the weights derived from
#' factor analysis, multiplies them out and then takes the sum of these weighted
#' indicator scores to get the final score for that domain.
#' The function takes a list of weights (generated by \code{\link{getFAWeights}}) and a
#' data.frame of normalised scores, it returns a numeric vector containing the
#' combined domain score.
#'
#' @param weights a list of weights generated by \code{\link{getFAWeights}}
#' @param norms a data.frame of normalised indicator values generated by \code{\link{normalScores}}
#'
#' @keywords SIMD, openSIMD, simdr
#'
#' @export
combineWeightsAndNorms <- function(weights, norms) {

  combined <- purrr::map2(weights, norms, ~ .x * .y)

  combined %>% data.frame %>% rowSums

}
TheDataLabScotland/simdr documentation built on May 29, 2019, 1:05 p.m.