8.10 Summarising factors with finalfit
Our own finalfit package provides convenient functions to summarise and compare factors, producing final tables for publication.
library(finalfit)
meldata %>%
summary_factorlist(dependent = "status_dss",
explanatory = "ulcer.factor")
label | levels | Alive | Died melanoma |
---|---|---|---|
Ulcerated tumour | Absent | 99 (66.9) | 16 (28.1) |
Present | 49 (33.1) | 41 (71.9) |
finalfit
is useful for summarising multiple variables.
We often want to summarise more than one factor or continuous variable against our dependent
variable of interest.
Think of Table 1 in a journal article.
Any number of continuous or categorical explanatory variables can be added.
library(finalfit)
meldata %>%
summary_factorlist(dependent = "status_dss",
explanatory =
c("ulcer.factor", "age.factor",
"sex.factor", "thickness")
)
label | levels | Alive | Died melanoma |
---|---|---|---|
Ulcerated tumour | Absent | 99 (66.9) | 16 (28.1) |
Present | 49 (33.1) | 41 (71.9) | |
Age (years) | ≤20 | 6 (4.1) | 3 (5.3) |
21 to 40 | 30 (20.3) | 7 (12.3) | |
41 to 60 | 66 (44.6) | 26 (45.6) | |
>60 | 46 (31.1) | 21 (36.8) | |
Sex | Female | 98 (66.2) | 28 (49.1) |
Male | 50 (33.8) | 29 (50.9) | |
thickness | Mean (SD) | 2.4 (2.5) | 4.3 (3.6) |