summarize: Summarize a Data Frame/Matrix/Vector

Description Usage Arguments Value Examples

Description

Takes in a data frame/matrix/vector and calculates summary statistics based on the type. If get_table is TRUE, returns a table of counts as well.

Usage

1
2
3
summarize_vec(vec, as_vec = FALSE, get_table = FALSE, useNA = "ifany")

summarize_df(data, as_vec = FALSE, get_table = FALSE, useNA = "ifany")

Arguments

vec

Atomic vector.

as_vec

Whether to return the values as a named vector instead of a list (logical).

get_table

Whether to tabulate the vector as well.

useNA

Value to pass to table to determine whether or not to use NA values (one of "no", "ifany", and "always").

data

A data frame/matrix/vector.

Value

List of summary statistics.

List of lists of summary statistics.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
summarize_vec(mtcars$mpg)
summarize_vec(mtcars$mpg, as_vec = TRUE)
summarize_vec(mtcars$mpg, get_table = TRUE)
summarize_vec(rownames(mtcars))
summarize_vec(c(1, 1, 1, 2, 2, NA), get_table = TRUE)
summarize_vec(c(1, 1, 1, 2, 2, NA), get_table = TRUE, useNA = "no")
summarize_vec(sample(c(TRUE, FALSE), 10, replace = TRUE))
summarize_vec(sample(c(TRUE, FALSE), 10, replace = TRUE), as_vec = TRUE)

summarize_df(mtcars)
summarize_df(mtcars, as_vec = TRUE)
summarize_df(mtcars, get_table = TRUE)

KO112/KO documentation built on Oct. 2, 2020, 9:21 a.m.