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")
TABLE 8.1: Two-by-two table with finalfit: Died with melanoma by tumour ulceration status.
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")
  )
TABLE 8.2: Multiple variables by outcome: Outcome after surgery for melanoma by patient and disease factors.
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)