View source: R/function-map-seq.R
| function_map_seq | R Documentation |
*_map_seq() functionsfunction_map_seq() creates a sequence mapper from a basic
mapper such as grim_map(): a function that varies the reported values
a few steps up and down and tests each resulting value set, as
grim_map_seq() does. By default, only inconsistent value sets are
dispersed.
See vignette("consistency-tests-in-depth"), section Sequence mapper.
function_map_seq() is a developer tool: it may change in a minor
release, with a NEWS entry.
function_map_seq(
.fn,
.var = .reported,
.reported,
.name_test,
.name_key_result = "consistency",
.name_class = NULL,
.args_disabled = NULL,
.dispersion = 1:5,
.out_min = "auto",
.out_max = "auto",
.var_bounds = NULL,
.include_reported = FALSE,
.include_consistent = FALSE,
...
)
.fn |
A basic mapper function such as |
.var |
String. The variables that the factory-made function disperses
by default. Defaults to |
.reported |
String. All variables the factory-made function can disperse. |
.name_test |
String (length 1). Plain-text name of the test, such as
|
.name_key_result |
(Experimental) String (length 1). Name of the key
result column. Default is |
.name_class |
String. Optionally, one or more classes to add to the
output. Default is |
.args_disabled |
String. Optionally, names of arguments of |
.dispersion |
Numeric. Steps up and down from the reported values, in
units of the last decimal place. Default is |
.out_min, .out_max |
Limits on the dispersed values. A number applies to
every dispersed variable, and |
.var_bounds |
Named list, or |
.include_reported |
Logical. Should the reported values themselves be
part of the sequences? Default is |
.include_consistent |
Logical. Should consistent value sets be
dispersed as well? Default is |
... |
These dots must be empty. |
The arguments of function_map_seq() set the defaults of the
corresponding arguments of the factory-made function, which can be
overridden in each call.
Each variable in var is dispersed around its own reported value while
the others stay as reported.
To export a factory-made function from another package, follow the
purrr FAQ on adverbs;
see vignette("consistency-tests-in-depth"), section Context and
export.
A function such as these:
| Factory-made function | Dispersed variables | Test vignette |
grim_map_seq() | "x", "n" | vignette("grim-in-depth") |
grimmer_map_seq() | "x", "sd", "n" | vignette("grimmer-in-depth") |
debit_map_seq() | "x", "sd", "n" | vignette("debit") |
The settings of .fn, i.e., its arguments after ..., such as
rounding, are arguments of this function as well, with the same
defaults. So are its helper arguments, such as items_averaged. Its ...
pass any other arguments on to .fn, which is only of use for a .fn
without ... of its own.
Name the factory-made function after .fn with
_seq appended, as in grim_map_seq() from grim_map(). The output
has the classes "scrutiny_map_seq" and
"scrutiny_{tolower(.name_test)}_map_seq". Prefix any class you add via
.name_class with your package's name, as in "mypkg_schlim_map_seq".
# Function definition of `grim_map_seq()`:
grim_map_seq <- function_map_seq(
.fn = grim_map,
.reported = c("x", "n"),
.name_test = "GRIM"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.