We will continue to work with the same data as in the previous set of
exercises. By now, you should (hopefully) have saved them as an
.rds file and, hence, be able to easily load them (in case
they are not already/still in your current R
workspace/working environment). This time, in addition to
base R and the tidyverse, we also need the
janitor package.
allbus_2021_eda <- readRDS("./data/allbus_2021_eda.rds")
base R, print a simple table with the frequencies of
the variable agec. Also include the counts for missing
values.
useNA = "always".
base R functions to get the
proportions for the variable sex rounded to four decimal
places.
table() into two other functions: One for
creating the proportion table and another one for rounding the decimal
places.
dplyr package to get the
frequencies and proportions for the sex variable (without
worrying about the number of decimal places this time).
janitor
package to display the counts and percentages for the categories in the
agec variable. The output sbe rounded to 3 decimal places
and include percentage signs.
tabyl() output using the
adorn_pct_formatting function.