Learn R Programming

DEXiR (version 1.0.2)

plotalt_parallel: plotalt_parallel

Description

Makes and plots DEXi alternatives on parallel axes, corresponding to attributes. Generally, axes are uniformly scaled to the [0,1] interval.

Usage

plotalt_parallel(
  model,
  alternatives = NULL,
  attids = NULL,
  aggregate = c("minmax", "min", "max", "mean", "none"),
  name = "name",
  shift = 0.01,
  linewidth = 2,
  pointsize = 3,
  split = c("no", "h", "v")
)

Value

A 'ggplot2' chart, enhanced with additional graph layers.

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

One of "minmax", "min", "max", "mean" or "none". Determines how to aggregate alternatives values that are represented by sets or distributions.

name

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

shift

numeric(1). Used to "shift" numeric results by a small amount to avoid overlapping lines in charts. Default: 0.01. You may want to experiment with charts to determine the right value,

linewidth

numeric(1). Widths of lines drawn.

pointsize

numeric(1). Size of points drawn.

split

One of:

"no"

Draw all alternatives on the same chart.

"v"

Split the chart vertically and draw alternatives separately.

"h"

Split the chart horizontally and draw alternatives separately.

Details

Data presented in the chart is prepared by scale_alternatives(). plotalt_parallel() invokes ggplot_parallel() to make a basic chart and then enhances it with graphic layers that are suitable for presenting DEXi alternatives.

See Also

scale_alternatives(), ggplot_parallel()

Examples

Run this code
if (requireNamespace("GGally", quietly = TRUE)) {

# Load "Car.dxi"
CarDxi <- system.file("extdata", "Car.dxi", package = "DEXiR")
Car <- read_dexi(CarDxi)

# Plot all Car$alternatives with points and lines
plotalt_parallel(Car)

# Show alternatives on two separate chart segments, shown one above the other.
plotalt_parallel(Car, split = "v")

alts3 <- structure(
list(
  name = c("MyCar", "MyCar2", "MyCar1b"),
    CAR.1 = list(4L, 4L, c(1L, 4L)),
    PRICE = list(3L, 3L, c(1L, 3L)),
    BUY.PRICE = list(3L, 3L, 3L),
    MAINT.PRICE = list(2, 1, structure(c(0.1, 0.6, 0.3), class = "distribution")),
    TECH.CHAR. = list(3L, 3:4, 3L),
    COMFORT = list(3L, 2, 3L),
    X.PERS = list(3, 3, 3L),
    X.DOORS = list(3, 3, 3L),
    LUGGAGE = list(2L, 2L, 2),
    SAFETY = list(2, c(2, 3), 2)
    ),
    row.names = c(NA, -3L),
    class = "data.frame"
 )

# Plot `alts2` with points and lines.
# Notice the "minmax" aggregation of sets and distributions.
plotalt_parallel(Car, alts3)
plotalt_parallel(Car, alts3, split = "v")

# Now with "mean" aggregation
plotalt_parallel(Car, alts3, split = "v", aggregate = "mean")
}

Run the code above in your browser using DataLab