
show.pref(p, df = NULL)pref.str(p, df = NULL)
eval.pref(p, df = NULL)
## S3 method for class 'preference':
as.character(x, ...)
as.character
.show.pref
and pref.str
have the optional paramter df
.
If this paramter is given, these functions call eval.pref
before they output or return the preference string.
The following equalities hold:as.character(eval.pref(p, df)) == pref.str(p, df)
show(eval.pref(p, df))
produces the same console output asshow.pref(p, df)
pref.str
(or as.character(p)
for a preference p
) returns the preference string
while show.pref
outputs it directly to the console, preceded by '[Preference]'
.
If df
is specified, then a partial evaluation of the preference is done before converting it to a string.The function eval.pref
(with given dataframe df
) partially evaluates the internal preference expression and
returns again a preference object. All expressions in p
are evaluated in the environment
where p
was defined, except the the column names in df
(which are potential attributes in p
)
and except the special variable df__
, which accesses the entire data set (see psel
).
The content of the dataframe df
does not matter; only names(df)
is used to get the "free variables" in p
.
f <- function(x) 2*x
p <- true(cyl == f(1))
# prints 'cyl == f(x)'
p
# prints 'cyl == 2'
show.pref(p, mtcars)
eval.pref(p, mtcars)
Run the code above in your browser using DataLab