Learn R Programming

DEXiR (version 1.0.2)

scale_alternatives: scale_alternatives

Description

A helper function for preparing alternatives' data for charts that involve multiple attributes (such as plotalt_parallel()) and plotalt_radar()). scale_alternatives() carries out three main operations:

  1. Aggregates DEXi values, represented by sets and distributions, into single numeric values, using one of the aggregate operators: "minmax", "min", "max" or "mean",

  2. scales the aggregated values to the [0,1] interval so that they can be drawn uniformly on multiple chart axes,

  3. optionally "shifts" the values by a small amount to avoid overlapping chart lines.

Usage

scale_alternatives(
  model,
  alternatives = NULL,
  attids = NULL,
  aggregate = c("minmax", "min", "max", "mean", "none"),
  name = "name",
  shift = 0.01
)

Value

A list containing the elements:

data

A data frame containing the aggregated/scaled/shifted numeric values.

nalt

The number of alternatives. Notice that with aggregate = "minmax", data contains twice as many rows.

groups

A numeric vector mapping data rows to alternatives' indices.

altnames

Names of alternatives.

Arguments

model

A DexiModel object. Required.

alternatives

A data.frame of alternatives (normally an output of evaluate()) or indices to model$alternatives. The default value NULL selects the whole model$alternatives.

attids

character(). A character vector of DexiAttribute IDs to be included in the result. Default: all model attributes.

aggregate

Determines how to aggregate DEXi values that are represented/interpreted as sets in alternatives:

"min"

Uses the function min() to take the minimal set element.

"max"

Uses the function max() to take the maximal set element.

"mean"

Uses the function mean() to take the average set value.

"minmax" (default)

Takes both "min" and "max", so that each alternative appears in the result twice.

"none"

No aggregation.

Any distributions that appear in alternatives are interpreted as sets prior to aggregation. The default operator "minmax" is suitable particularly for alternatives containing non-single-values (sets and/or distributions). For alternatives containing only single numeric values, any of the other three operators is preferred.

name

character(1), The name of the column in alternatives that contains alternatives' names. Default: "name".

shift

numeric(1). Used to "shift" numerical values by a small amount to avoid overlapping lines in charts. Default: 0.01.

See Also

plotalt_parallel()), plotalt_radar())