This function will create a composite variable
composite(x, variables, type = "mean", standardize = FALSE, name = NULL, missing.allowed = NULL)
x | dataframe |
---|---|
variables | c() of columns to average together to create the composite |
type | What type of composite should be calculated?, i.e. mean or sum. (Default = "mean"). |
standardize | Logical. Do you want to calculate the composite based on standardize (z-score) values? (Default = FALSE) |
name | Name of the new composite variable |
missing.allowed | Criteria for how many variables can having missing values and still calculate a composite |
composite(x, variable = c(), type = "mean", name = "name")#> Error in transform(x, composite = rowMeans(x[variables], na.rm = TRUE)): object 'x' not found