Learn R Programming

DEXiR (version 1.0.2)

DexiDiscreteScale-class: DexiDiscreteScale

Description

DexiDiscreteScale is a RC class, derived from DexiScale, representing qualitative (symbolic, discrete, verbal) value scales in R. Such scales are typical for DEXi models and are the only scale type supported by the DEXi software. DEXiWin software supports both continuous and discrete scales.

Arguments

Fields

values

character. Vector of qualitative scale values. Example: scale$values <- c("low", "medium", "high").

nvals

integer. Equal to length(values).

quality

character. Vector of qualities, corresponding to values. Should be the of the same length as values. Example: scale$quality <- c("bad", "none", "good").

descriptions

character. A vector of textual descriptions of the corresponding values. Should be of the same length as values.

Methods

count()

Return the number of scale elements. Equal to NA for DexiScale, 0 for DexiContinuousScale, and equal to nvals >= 0 for DexiDiscreteScale.

equal(scl)

Check if this scale is equal to scale scl. Needed for attribute linking.

full_range()

Return the vector that represents the full range of values on this scale. Equal to NA for DexiScale and DexiContinuousScale, and 1 : scale$nvals for DexiDiscreteScale.

initialize(order = EnumOrder, ...)

Initialize a DexiScale object.

is_discrete()

Logical: Is this scale discrete?

to_string()

Return a string representation of this scale for printing.

value_index(value)

Find the index of value (character(1)) on this scale. Equal to NA for DexiScale and DexiContinuousScale. With DexiDiscreteScale objects, it returns a numeric index or NA of value in scale$values.

value_quality(value)

Return the quality (preferential class) of value on this scale: one of the strings "bad", "none" or "good". Always "none" for DexiScale and scales with order = "none".

verify()

Check the correctnes of this scale object and its fields. Result: error() or TRUE.

Details

An attribute associated with a discrete scale can take values from a finite (and usually small) set of string values contained in the character vector values. Additionally, each of these values is associated with one of the qualities "bad", "none" or "good". The latter are contained in the character vector quality, which is of the same length as values.

Examples

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

# For example, consider the scale of attribute PRICE
scl <- Car$attrib("PRICE")$scale

# Print fields and basic properties of scl
scl$verify()
scl$values
scl$quality
scl$descriptions
scl$nvals
scl$count()
scl$is_discrete()
scl$is_continuous()
scl$to_string()
scl$full_range()

# Find value indices
scl$value_index("medium")
scl$value_index("med")

# Is scl equal to the scale of BUY.PRICE?
scl$equal(Car$attrib("PRICE")$scale)

Run the code above in your browser using DataLab