Learn R Programming

rPref (version 0.1)

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
The value which should be in the preferred interval, layer, etc. The same requirements as for base_pref apply.
center
Preferred value, where a values from the given expr should be near by.
left
Lower limit for a preferred interval.
right
Upper limit for a preferred interval.
pos_value
The preferred value or set for a pos-preference.
...
Layers (sets) for a layered-Preference, where the first set are 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