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, df = NULL)
between(expr, left, right, df = NULL)
pos(expr, pos_value, df = NULL)
layered(expr, ..., df = NULL)
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 within the preferred interval, laye
center
Preferred numerical value for around.
df
(optional) Data frame for partial evaluation. See base_pref for details.
left
Lower limit (numerical) of the preferred interval for between.
right
Upper limit (numerical) of the preferred interval for between.
pos_value
A vector containing the preferred values for a pos preference.
This 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.
# search for cars where mpg is near to 25psel(mtcars, around(mpg, 25))
# cyl = 2 and cyl = 4 are equally good, cyl = 6 is worsepsel(mtcars, layered(cyl, c(2, 4), 6))