Learn R Programming

DEXiR (version 1.0.2)

plotalt_radar: plotalt_radar

Description

Plots DEXi alternatives on a radar chart. Generally, axes are uniformly scaled to the [0,1] interval.

Usage

plotalt_radar(
  model,
  alternatives = NULL,
  attids = NULL,
  aggregate = c("minmax", "min", "max", "mean", "none"),
  name = "name",
  shift = 0.01,
  linewidth = 2,
  ptype = 16,
  colors = NULL,
  unicolors = NULL,
  fillcolors = NULL,
  transparency = 85,
  circular = FALSE,
  split = FALSE,
  fill = FALSE,
  ...
)

Value

Draws a chart or, when split = TRUE a series of charts corresponding to individual 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

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 values 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.

ptype

A vector to specify point symbol: Default 16 (closed circle). Should be 32 to not plot the points. This vector is repeatedly used for data series.

colors

Colors to be used (repeatably) for data series. Default 1:8.

unicolors

A vector of one or two colors to be used for displaying the minimum and maximum data series, respectively. Applies only when split = TRUE.

fillcolors

A vector of color codes for filling polygons. Applies only when fill = TRUE.

transparency

A number between 0 and 100 representing the transparency of colors used for filling polygons.

circular

logical(1). Whether to make a circular (using fmsb::radarchartcirc()) or polygonal (fmsb::radarchart()) radar grid.

split

logical(1). Whether to plot all alternatives on a single chart (FALSE, default) or make a series of plots of individual alternatives (TRUE).

fill

logical(1). Whether or not to fill polygons using fillcolors.

...

Optional parameters passed to fmsb::radarchart().

Details

Uses fmsb::radarchart() and requires package "fmsb" to be installed. Data presented in the chart is prepared by scale_alternatives().

See Also

scale_alternatives(), fmsb::radarchart()

Examples

Run this code
if (requireNamespace("fmsb", 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_radar(Car)

# Use different colors and fill polygons
plotalt_radar(Car, colors = c("blue", "brown"), fill = TRUE)
plotalt_radar(Car, colors = c("blue", "brown"), fillcolors = c("green", "red"), fill = TRUE)

# Draw separate charts
plotalt_radar(Car, split = TRUE)

# Draw separate charts, using the same color settings on all charts
plotalt_radar(Car, split = TRUE, unicolors = c("green", "red"))
plotalt_radar(Car, split = TRUE, unicolors = c("green", "red"), circular = TRUE)

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"
 )

# The same chart types as above, but using more varied alternatives data
# Plot all Car$alternatives with points and lines
plotalt_radar(Car, alts3)

# Use different colors and fill polygons
plotalt_radar(Car, alts3, colors = c("blue", "brown", "purple"), fill = TRUE)
plotalt_radar(Car, alts3, colors = c("blue", "brown", "purple"),
  fillcolors = c("green", "red", "yellow"), fill = TRUE)

# Draw separate charts
plotalt_radar(Car, alts3, split = TRUE)
plotalt_radar(Car, alts3, split = TRUE, fill = TRUE)

# Draw separate charts, using the same color settings on all charts
plotalt_radar(Car, alts3, split = TRUE, unicolors = c("red", "green"))
plotalt_radar(Car, alts3, split = TRUE, unicolors = c("green", "darkgreen"), fill = TRUE)
plotalt_radar(Car, alts3, split = TRUE, unicolors = c("red", "green"), circular = TRUE)

}

Run the code above in your browser using DataLab