Learn R Programming

rPref (version 0.6)

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

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