tv {kim} | R Documentation |
Tabulate vector
Description
Shows frequency and proportion of unique values in a table format. This function is a copy of the earlier function, tabulate_vector, in Package 'kim'
Usage
tv(
vector = NULL,
na.rm = FALSE,
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 |
sort_by_decreasing_count |
if |
sort_by_increasing_count |
if |
sort_by_decreasing_value |
if |
sort_by_increasing_value |
if |
total_included |
if |
sigfigs |
number of significant digits to round to |
round_digits_after_decimal |
round to nth digit after decimal
(alternative to |
output_type |
if |
Value
if output_type = "dt"
, which is the default, the output
will be a data.table showing the count and proportion (percent) of each
element in the given vector; if output_type = "df"
, the output will
be a data.frame showing the count and proportion (percent) of each value
in the given vector.
Examples
tv(c("a", "b", "b", "c", "c", "c", NA))
tv(c("a", "b", "b", "c", "c", "c", NA),
sort_by_increasing_count = TRUE
)
tv(c("a", "b", "b", "c", "c", "c", NA),
sort_by_decreasing_value = TRUE
)
tv(c("a", "b", "b", "c", "c", "c", NA),
sort_by_increasing_value = TRUE
)
tv(c("a", "b", "b", "c", "c", "c", NA),
sigfigs = 4
)
tv(c("a", "b", "b", "c", "c", "c", NA),
round_digits_after_decimal = 1
)
tv(c("a", "b", "b", "c", "c", "c", NA),
output_type = "df"
)