tabulate_vector: Tabulate vector

Description Usage Arguments Value Examples

View source: R/tabulate_vector.R

Description

Shows frequency and proportion of unique values in a table format

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
tabulate_vector(
  vector = NULL,
  na.rm = TRUE,
  sort_by_decreasing_count = NULL,
  sort_by_increasing_count = NULL,
  sort_by_decreasing_value = NULL,
  sort_by_increasing_value = NULL,
  total_included = TRUE,
  sigfigs = NULL,
  round_digits_after_decimal = NULL,
  output_type = "dt"
)

Arguments

vector

a character or numeric vector

na.rm

if TRUE, NA values will be removed before calculating frequencies and proportions.

sort_by_decreasing_count

if TRUE, the output table will be sorted in the order of decreasing frequency.

sort_by_increasing_count

if TRUE, the output table will be sorted in the order of increasing frequency.

sort_by_decreasing_value

if TRUE, the output table will be sorted in the order of decreasing value.

sort_by_increasing_value

if TRUE, the output table will be sorted in the order of increasing value.

total_included

if TRUE, the output table will include a row for total counts.

sigfigs

number of significant digits to round to

round_digits_after_decimal

round to nth digit after decimal (alternative to sigfigs)

output_type

if output_type = "df", return a data.frame. By default, output_type = "dt", which will return a data.table.

Value

a data.table or data.frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
tabulate_vector(c("a", "b", "b", "c", "c", "c", NA))
tabulate_vector(c("a", "b", "b", "c", "c", "c", NA),
sort_by_increasing_count = TRUE)
tabulate_vector(c("a", "b", "b", "c", "c", "c", NA),
sort_by_decreasing_value = TRUE)
tabulate_vector(c("a", "b", "b", "c", "c", "c", NA),
sort_by_increasing_value = TRUE)
tabulate_vector(c("a", "b", "b", "c", "c", "c", NA),
sigfigs = 4)
tabulate_vector(c("a", "b", "b", "c", "c", "c", NA),
round_digits_after_decimal = 1)
tabulate_vector(c("a", "b", "b", "c", "c", "c", NA),
output_type = "df")

jinkim3/ezr documentation built on April 18, 2021, 3:33 a.m.