R/composite.sum.R

Defines functions composite.sum

Documented in composite.sum

#' A Data Transformation Function
#' 
#' This function will create a composite variable, from the sum of variables()
#' @param x dataframe
#' @param variables c() of columns to sum together to create the composite
#' @param name Name of the new composite variable
#' @keywords composite
#' @export 
#' @examples 
#' composite.sum(x, variable = c(), name = "name")

composite.sum <- function (x, variables = c(), name = ""){
  x <- transform(x, composite = rowSums(x[variables], na.rm = TRUE))
  names(x)[length(x)] <- name
  return(x)
}
dr-JT/datatransform documentation built on June 10, 2018, 6:31 p.m.