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")

1

Using base R, print a simple table with the frequencies of the variable agec. Also include the counts for missing values.
The argument for including missing values in the resulting table is useNA = "always".

2

Next, use a combination of base R functions to get the proportions for the variable sex rounded to four decimal places.
You need to wrap table() into two other functions: One for creating the proportion table and another one for rounding the decimal places.

3

Now, use functions from the dplyr package to get the frequencies and proportions for the sex variable (without worrying about the number of decimal places this time).
We first need to count the cases and then transform the resulting variable to get proportions.

4

As a final exercise, use a function from the 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.
You can format the tabyl() output using the adorn_pct_formatting function.