Learn R Programming

prefio (version 0.2.0)

pref_cov: Covariance matrix for preferences, calculated using the rankings matrix.

Description

Covariance matrix for preferences, calculated using the rankings matrix.

Usage

pref_cov(x, preferences_col = NULL, frequency_col = NULL, ...)

Value

A covariance matrix containing covariances for the ranks assigned to item pairs.

Arguments

x

A vector of preferences, or a tibble with a column of preferences.

preferences_col

<tidy-select> When x is a tibble, the column containing the preferences.

frequency_col

<tidy-select> When x is a tibble, the column containing the frequency of the preferences. If not provided, each row is considered to be observed a single time.

...

Extra arguments to be passed to stats::cov.wt.

Examples

Run this code
# Simple covariance on a vector of preferences
prefs <- preferences(c("a > b > c", "b > c > a", "c > a > b"))
pref_cov(prefs)

# Weighted covariance by frequency
df <- tibble::tibble(
  prefs = preferences(c("a > b > c", "b > c > a")),
  freq = c(3, 2)
)
pref_cov(df, preferences_col = prefs, frequency_col = freq)

Run the code above in your browser using DataLab