R: Set or add the summary functions for a particular type of...

skim_with {skimr} | R Documentation

## Set or add the summary functions for a particular type of data

### Description

While skim is designed around having an opinionated set of defaults, you can use these functions to change the summary statistics that it returns. To do that, provide type you wish to change as an argument to this function, along with a list of named functions that you want to use instead of the defaults.

### Usage

    skim_with(..., append = TRUE)

    skim_with_defaults()

    show_skimmers(which = NULL)

    get_skimmers(which = NULL)

### Arguments

`...` | A list of functions, with an argument name that matches a particular data type.
`append` | Whether the provided options should be in addition to the defaults already in `skim`. Default is `TRUE`.
`which` | A character vector. One or more of the classes whose summary functions you wish to display.

### Details

This function is not pure. It sets values in within the package environment. This is an intentional design choice, with effects similar to setting options in base R. By setting options here for your entire session, you can continue to summarize using skim on its own.

### Value

When setting values, `invisible(NULL)`. When looking up values a list. The names of the list match the classes that have assigned summary functions. With `show_skimmers()`, each entry in the list is a character vector of function names. With `get_skimmers()`, each entry in the list is itself a list of named functions.

### Functions

- `skim_with_defaults`: Use the default functions within skim

- `show_skimmers`: Access the names of the summary functions for a class.

- `get_skimmers`: Pull a list of summary functions for a class.

### Examples

    # Use new functions for numeric functions
    skim_with(numeric = list(median = median, mad = mad), append = FALSE)
    skim(faithful)

    # If you want to remove a particular skimmer, set it to NULL
    # This removes the inline histogram
    skim_with(numeric = list(hist = NULL))
    skim(faithful)

    # This works with multiple skimmers. Just match names to overwrite
    skim_with(numeric = list(iqr = IQR, p25 = NULL, p75 = NULL))
    skim(faithful)

    # Alternatively, set `append = FALSE` to replace the skimmers of a type.
    skim_with(numeric = list(mean = mean, sd = sd), append = FALSE)

    # Skimmers are unary functions. Partially apply arguments during assigment.
    # For example, you might want to remove NA values.
    skim_with(numeric = list(iqr = purrr::partial(IQR, na.rm = TRUE)))

    # Or use an rlang-style formula constructor for the function
    skim_with(numeric = list(med = ~median(., na.rm = TRUE)))

    # Go back to defaults
    skim_with_defaults()
    skim(faithful)

    # What are the names of the numeric skimmers?
    show_skimmers("numeric")

    # I want to create a set of skimmers for the hms class, using the date
    # skimmers currently available.
    funs <- get_skimmers()
    skim_with(hms = funs$date)

[Package skimr version 1.0.2 Index]