Learn R Programming

rPref (version 0.5)

base_pref_macros: Useful base preference macros

Description

In addition to the fundamental base preferences, rPref offers some macros to define preferences where a given interval or point is preferred.

Usage

around(expr, center)

between(expr, left, right)

pos(expr, pos_value)

layered(expr, ...)

Arguments

expr
A numerical expression (for around and between) or an arbitrary expression (for pos and layered). The objective are tuples where expr evaluates to a value in the preferred interval, layer, e
center
Preferred value for around.
left
Lower limit of the preferred interval for between.
right
Upper limit of the preferred interval for between.
pos_value
A vector containing the preferred values for a pos preference. Has to be of the same type (numeric, logical, character, ...) as expr.
...
Layers (sets) for a layered preference. Each variable corresponds to one layer and the first set characterizes the most preferred values.

Examples

Run this code
# Search for cars where mpg is near to 25
psel(mtcars, around(mpg, 25))

# cyl = 2 and cyl = 4 are equally good, cyl = 6 is worse
psel(mtcars, layered(cyl, c(2, 4), 6))

Run the code above in your browser using DataLab