Skip to contents

Calculate the weighted similarity matrix for a set of factors in a data frame.

Usage

weighted_factor_sim(des, wts = rep(1, ncol(des))/ncol(des))

Arguments

des

A data frame containing factors for which the weighted similarity matrix will be computed.

wts

A numeric vector of weights corresponding to the factors in the data frame. The default is equal weights for all factors.

Value

A weighted similarity matrix computed for the factors in the data frame.

Examples

des <- data.frame(
  var1 = factor(c("a", "b", "a", "b", "a")),
  var2 = factor(c("c", "c", "d", "d", "d"))
)

sim_default_weights <- weighted_factor_sim(des)

sim_custom_weights <- weighted_factor_sim(des, wts = c(0.7, 0.3))