Skip to contents

This function creates two matrices from an input data frame by pivoting the data into a wide format: one matrix for utilities and another for probabilities.

Usage

prepare_turf_data(data, id, attribute, utilities, probability, weights = NULL)

Arguments

data

A data frame containing the data.

id

A character string indicating the column name for the unique identifier.

attribute

A character string indicating the column name for the attribute.

utilities

A character string specifying the column name for the utility values.

probability

A character string specifying the column name for the probability values.

weights

A character string specifying the column name for weights. By default (NULL) it sets weights as 1.

Value

A list containing two matrices:

attributes

A factor vector of attribute names.

utilities

A matrix of utility values.

probabilities

A matrix of probability values.

Examples

if (FALSE) { # \dontrun{
# Create the matrices
result <- prepare_turf_data(
  data = example_md_turf_data,
  id = "id",
  attribute = "item",
  utilities = "pwu",
  probability = "probability"
)

# View the matrices
result$attributes
head(result$utilities)
head(result$probabilities)
} # }