skim_with | R Documentation |
While skim is designed around having an opinionated set of defaults, you can use this function to change the summary statistics that it returns.
skim_with( ..., base = sfl(n_missing = n_missing, complete_rate = complete_rate), append = TRUE )
... |
One or more ( |
base |
An |
append |
Whether the provided options should be in addition to the
defaults already in |
skim_with()
is a closure: a function that returns a new function. This
lets you have several skimming functions in a single R session, but it
also means that you need to assign the return of skim_with()
before
you can use it.
You assign values within skim_with
by using the sfl()
helper (skimr
function list). This helper behaves mostly like dplyr::funs()
, but lets
you also identify which skimming functions you want to remove, by setting
them to NULL
. Assign an sfl
to each column type that you wish to modify.
Functions that summarize all data types, and always return the same type
of value, can be assigned to the base
argument. The default base skimmers
compute the number of missing values n_missing()
and the rate of values
being complete, i.e. not missing, complete_rate()
.
When append = TRUE
and local skimmers have names matching the names of
entries in the default skim_function_list
, the values in the default list
are overwritten. Similarly, if NULL
values are passed within sfl()
, these
default skimmers are dropped. Otherwise, if append = FALSE
, only the
locally-provided skimming functions are used.
Note that append
only applies to the typed
skimmers (i.e. non-base).
See get_default_skimmer_names()
for a list of defaults.
A new skim()
function. This is callable. See skim()
for more
details.
# Use new functions for numeric functions. If you don't provide a name, # one will be automatically generated. my_skim <- skim_with(numeric = sfl(median, mad), append = FALSE) my_skim(faithful) # If you want to remove a particular skimmer, set it to NULL # This removes the inline histogram my_skim <- skim_with(numeric = sfl(hist = NULL)) my_skim(faithful) # This works with multiple skimmers. Just match names to overwrite my_skim <- skim_with(numeric = sfl(iqr = IQR, p25 = NULL, p75 = NULL)) my_skim(faithful) # Alternatively, set `append = FALSE` to replace the skimmers of a type. my_skim <- skim_with(numeric = sfl(mean = mean, sd = sd), append = FALSE) # Skimmers are unary functions. Partially apply arguments during assigment. # For example, you might want to remove NA values. my_skim <- skim_with(numeric = sfl(iqr = ~ IQR(., na.rm = TRUE))) # Set multiple types of skimmers simultaneously. my_skim <- skim_with(numeric = sfl(mean), character = sfl(length)) # Or pass the same as a list, unquoting the input. my_skimmers <- list(numeric = sfl(mean), character = sfl(length)) my_skim <- skim_with(!!!my_skimmers) # Use the v1 base skimmers instead. my_skim <- skim_with(base = sfl( missing = n_missing, complete = n_complete, n = length )) # Remove the base skimmers entirely my_skim <- skim_with(base = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.