trim {trimmer} | R Documentation |
Trim an R Object
Description
Trims an R object whilst presuming the results of a given function call,
where the R object is given as an argument. One popular example could be
trimming an R model object whilst presuming the results of the
predict
function on a sample of data.
Usage
trim(obj, obj_arg_name = NULL, fun = predict, size_target = 0,
tolerate_warnings = FALSE, verbose = TRUE, dont_touch = list(),
...)
Arguments
obj |
|
obj_arg_name |
|
fun |
|
size_target |
|
tolerate_warnings |
|
verbose |
|
dont_touch |
|
... |
other (named) arguments for 'fun'. |
Examples
# get training data for predictive model.
trn <- datasets::mtcars
# estimate model.
mdl <- lm(mpg ~ ., data = trn)
trim(obj = mdl, obj_arg_name = "object", fun = predict, newdata = trn)
trim(obj = mdl, obj_arg_name = "object", fun = predict, newdata = trn,
dont_touch = list(c("model"), c("qr","tol")))