RDocumentation: summary_factorlist
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    Note that this notebook was automatically generated from an RDocumentation page. It depends on the package and the example code whether this code will run without errors. You may need to edit the code to make things work.

    if(!require('finalfit')) {
        install.packages('finalfit')
        library('finalfit')
    }
    library(finalfit)
    library(dplyr)
    # Load example dataset, modified version of survival::colon
    data(colon_s)
    
    # Table 1 - Patient demographics ----
    explanatory = c("age", "age.factor", "sex.factor", "obstruct.factor")
    dependent = "perfor.factor"
    colon_s %>%
      summary_factorlist(dependent, explanatory, p=TRUE)
    
    # summary.factorlist() is also commonly used to summarise any number of
    # variables by an outcome variable (say dead yes/no).
    
    # Table 2 - 5 yr mortality ----
    explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
    dependent = "mort_5yr"
    colon_s %>%
      summary_factorlist(dependent, explanatory)