
Last chance! 50% off unlimited learning
Sale ends in
Shows frequency and proportion of unique values in a table format
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"
)
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.
a character or numeric vector
if TRUE
, NA values will be removed before calculating
frequencies and proportions.
if TRUE
, the output table will
be sorted in the order of decreasing frequency.
if TRUE
, the output table will
be sorted in the order of increasing frequency.
if TRUE
, the output table will
be sorted in the order of decreasing value.
if TRUE
, the output table will
be sorted in the order of increasing value.
if TRUE
, the output table will include
a row for total counts.
number of significant digits to round to
round to nth digit after decimal
(alternative to sigfigs
)
if output_type = "df"
, return a data.frame.
By default, output_type = "dt"
, which will return a data.table.
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"
)
Run the code above in your browser using DataLab