Title: | Trim an Object |
Version: | 0.8.1 |
Description: | A lightweight toolkit to reduce the size of a list object. The object is minimized by recursively removing elements from the object one-by-one. The process is constrained by a reference function call specified by the user, where the target object is given as an argument. The procedure will not allow elements to be removed from the object, that will cause results from the function call to diverge from the function call with the original object. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
LazyData: | true |
Suggests: | testthat (≥ 2.1.0), knitr, rmarkdown |
Imports: | data.table, crayon, cli, pryr |
RoxygenNote: | 6.1.1 |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2019-12-18 19:39:56 UTC; Lars |
Author: | Lars Kjeldgaard [aut, cre] |
Maintainer: | Lars Kjeldgaard <lars_kjeldgaard@hotmail.com> |
Repository: | CRAN |
Date/Publication: | 2019-12-18 22:30:10 UTC |
Adjust Data Table with Candidate Elements for Elimination
Description
Adjusts positions of all candidates for elimination in data.table after removing a candidate (due to the fact, that the positions may shift).
Usage
adjust_candidates(cand, cand_top_idx)
Arguments
cand |
|
cand_top_idx |
|
Value
data.table
candidates after any adjustments to position
indices of candidates.
Convert Numbered Index to Named Index of List Element
Description
Convert Numbered Index to Named Index of List Element
Usage
convert_idx_to_name(vec, obj)
Arguments
vec |
|
obj |
|
Value
character
named index of list element.
Examples
d <- list(a = list(b = list(c = 3, d = 5), e = c(2,4)))
num_idx <- c(1,1,2)
convert_idx_to_name(num_idx, d)
Fix til at undgå R CMD check notes for "no visible binding for global variable"
Description
Dette script gør det muligt at referere til kolonner i data frames ved hjælp af Non Standard Evaluation (NSE) i databehandlingspakker som data.table og dplyr, uden at dette medfører R CMD check notes angående "no visible binding for global variable". Navnene på de variable, der refereres til ved hjælp af NSE, skal blot angives i en vektor til funktionen globalVariables() nedenfor.
Usage
fix_undefined_global_vars()
Details
Dette er den anbefalede løsning fra CRAN.
Compute Results From Function Call with Object as Argument
Description
Compute Results From Function Call with Object as Argument
Usage
get_results_for_object(obj, obj_arg_name, fun, ...,
tolerate_warnings = TRUE)
Arguments
obj |
|
obj_arg_name |
|
fun |
|
... |
other (named) arguments for 'fun'. |
tolerate_warnings |
|
Value
results from function call.
Convert Size in Bytes to Print Friendly String
Description
Convert Size in Bytes to Print Friendly String
Usage
pf_obj_size(x, digits = 2)
Arguments
x |
|
digits |
|
Value
character
priend friendly string.
Examples
pf_obj_size(10)
pf_obj_size(1010)
pf_obj_size(2e06)
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")))