descriptives {cheese}R Documentation

Compute descriptive statistics on columns of a data frame

Description

The user can specify an unlimited number of functions to evaluate and the types of data that each set of functions will be applied to (including the default; see "Details").

Usage

descriptives(
    data,
    f_all = NULL,
    f_numeric = NULL,
    numeric_types = "numeric",
    f_categorical = NULL,
    categorical_types = "factor",
    f_other = NULL,
    useNA = c("ifany", "no", "always"),
    round = 2,
    na_string = "(missing)"
)

Arguments

data

A data.frame.

f_all

A list of functions to evaluate on all columns.

f_numeric

A list of functions to evaluate on numeric_types columns.

numeric_types

Character vector of data types that should be evaluated by f_numeric.

f_categorical

A list of functions to evaluate on categorical_types columns.

categorical_types

Character vector of data types that should be evaluated by f_categorical.

f_other

A list of functions to evaluate on remaining columns.

useNA

See table for details. Defaults to "ifany".

round

Digit to round numeric data. Defaults to 2.

na_string

String to fill in NA names.

Details

The following fun_key's are available by default for the specified types:

Value

A tibble::tibble with the following columns:

Author(s)

Alex Zajichek

Examples

#Default
heart_disease %>%
    descriptives()

#Allow logicals as categorical
heart_disease %>%
    descriptives(
        categorical_types = c("logical", "factor")
    ) %>%
    
    #Extract info from the column
    dplyr::filter(
        col_lab == "BloodSugar"
    ) 

#Nothing treated as numeric
heart_disease %>%
    descriptives(
        numeric_types = NULL
    )

#Evaluate a custom function
heart_disease %>%
    descriptives(
        f_numeric = 
            list(
                cv = function(x) sd(x, na.rm = TRUE)/mean(x, na.rm = TRUE)
            )
    ) %>%
    
    #Extract info from the custom function
    dplyr::filter(
        fun_key == "cv"
    ) 


[Package cheese version 0.1.2 Index]