8.14 Exercises

8.14.1 Exercise

Using finalfit, create a summary table with “status.factor” as the dependent variable and the following as explanatory variables: sex.factor, ulcer.factor, age.factor, thickness.

Change the continuous variable summary statistic to median and interquartile range instead of mean and sd.

8.14.2 Exercise

By changing one and only one line in the following block create firstly a new table showing the breakdown of status.factor by age and secondly the breakdown of status.factor by sex:

meldata %>%
  count(ulcer.factor, status.factor) %>%
  group_by(status.factor) %>%
  mutate(total = sum(n)) %>%
  mutate(percentage = round(100*n/total, 1)) %>% 
  mutate(count_perc = paste0(n, " (", percentage, ")")) %>% 
  select(-total, -n, -percentage) %>% 
  spread(status.factor, count_perc)

8.14.3 Exercise

Now produce these tables using the summary_factorlist() function from the finalfit package.