weighted_factor_sim | R Documentation |
Calculate the weighted similarity matrix for a set of factors in a data frame.
weighted_factor_sim(des, wts = rep(1, ncol(des))/ncol(des))
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. |
A weighted similarity matrix computed for the factors in the data frame.
# Sample data
des <- data.frame(
var1 = factor(c("a", "b", "a", "b", "a")),
var2 = factor(c("c", "c", "d", "d", "d"))
)
# Compute similarity matrix with default equal weights
sim_default_weights <- weighted_factor_sim(des)
# Compute similarity matrix with custom weights
sim_custom_weights <- weighted_factor_sim(des, wts = c(0.7, 0.3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.