vals | R Documentation |
Akin to 1-dimensional table
with a few differences:
it returns as a dataframe,
it always includes NA
s,
it includes the proportion of elements,
it can take a vals(df, var)
input format for easy chaining,
it will include value labels when sjlabelled::is_labelled
.
vals(data, var = NULL, digits = 2)
data |
Either a vector, or a dataframe in which to find |
var |
When |
digits |
Optional argument to round proportions to specific number of digits (default is 2). |
Note that the cum.prop
column in resulting dataframe was calculated after
sorting based on value. It will not remain correct if resorted.
# first input format uses a (df, name) specification like dplyr
vals(mtcars, gear)
# second input format just takes a vector
vals(mtcars$gear)
# with NAs
vals(mice::boys, gen)
# with more decimals in proportions
vals(mice::boys$gen, digits = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.