sbalci/ClinicoPathJamoviModule

View on GitHub
R/survival.h.R

Summary

Maintainability
Test Coverage

# This file is automatically generated, you probably don't want to edit this

survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "survivalOptions",
    inherit = jmvcore::Options,
    public = list(
        initialize = function(
            elapsedtime = NULL,
            tint = FALSE,
            dxdate = NULL,
            fudate = NULL,
            explanatory = NULL,
            outcome = NULL,
            outcomeLevel = NULL,
            dod = NULL,
            dooc = NULL,
            awd = NULL,
            awod = NULL,
            analysistype = "overall",
            cutp = "12, 36, 60",
            timetypedata = "ymd",
            timetypeoutput = "months",
            uselandmark = FALSE,
            landmark = 3,
            pw = FALSE,
            padjustmethod = "holm",
            ph_cox = FALSE,
            sc = FALSE,
            kmunicate = FALSE,
            ce = FALSE,
            ch = FALSE,
            endplot = 60,
            ybegin_plot = 0,
            yend_plot = 1,
            byplot = 12,
            multievent = FALSE,
            ci95 = FALSE,
            risktable = FALSE,
            censored = FALSE,
            pplot = TRUE, ...) {

            super$initialize(
                package="ClinicoPath",
                name="survival",
                requiresData=TRUE,
                ...)

            private$..elapsedtime <- jmvcore::OptionVariable$new(
                "elapsedtime",
                elapsedtime,
                suggested=list(
                    "continuous"),
                permitted=list(
                    "numeric"))
            private$..tint <- jmvcore::OptionBool$new(
                "tint",
                tint,
                default=FALSE)
            private$..dxdate <- jmvcore::OptionVariable$new(
                "dxdate",
                dxdate)
            private$..fudate <- jmvcore::OptionVariable$new(
                "fudate",
                fudate)
            private$..calculatedtime <- jmvcore::OptionOutput$new(
                "calculatedtime")
            private$..explanatory <- jmvcore::OptionVariable$new(
                "explanatory",
                explanatory,
                suggested=list(
                    "ordinal",
                    "nominal"),
                permitted=list(
                    "factor"))
            private$..outcome <- jmvcore::OptionVariable$new(
                "outcome",
                outcome,
                suggested=list(
                    "ordinal",
                    "nominal",
                    "continuous"),
                permitted=list(
                    "factor",
                    "numeric"))
            private$..outcomeLevel <- jmvcore::OptionLevel$new(
                "outcomeLevel",
                outcomeLevel,
                variable="(outcome)")
            private$..dod <- jmvcore::OptionLevel$new(
                "dod",
                dod,
                variable="(outcome)",
                allowNone=TRUE)
            private$..dooc <- jmvcore::OptionLevel$new(
                "dooc",
                dooc,
                variable="(outcome)",
                allowNone=TRUE)
            private$..awd <- jmvcore::OptionLevel$new(
                "awd",
                awd,
                variable="(outcome)",
                allowNone=TRUE)
            private$..awod <- jmvcore::OptionLevel$new(
                "awod",
                awod,
                variable="(outcome)",
                allowNone=TRUE)
            private$..analysistype <- jmvcore::OptionList$new(
                "analysistype",
                analysistype,
                options=list(
                    "overall",
                    "cause",
                    "compete"),
                default="overall")
            private$..outcomeredifened <- jmvcore::OptionOutput$new(
                "outcomeredifened")
            private$..cutp <- jmvcore::OptionString$new(
                "cutp",
                cutp,
                default="12, 36, 60")
            private$..timetypedata <- jmvcore::OptionList$new(
                "timetypedata",
                timetypedata,
                options=list(
                    "ymdhms",
                    "ymd",
                    "ydm",
                    "mdy",
                    "myd",
                    "dmy",
                    "dym"),
                default="ymd")
            private$..timetypeoutput <- jmvcore::OptionList$new(
                "timetypeoutput",
                timetypeoutput,
                options=list(
                    "days",
                    "weeks",
                    "months",
                    "years"),
                default="months")
            private$..uselandmark <- jmvcore::OptionBool$new(
                "uselandmark",
                uselandmark,
                default=FALSE)
            private$..landmark <- jmvcore::OptionInteger$new(
                "landmark",
                landmark,
                default=3)
            private$..pw <- jmvcore::OptionBool$new(
                "pw",
                pw,
                default=FALSE)
            private$..padjustmethod <- jmvcore::OptionList$new(
                "padjustmethod",
                padjustmethod,
                options=list(
                    "holm",
                    "hochberg",
                    "hommel",
                    "bonferroni",
                    "BH",
                    "BY",
                    "fdr",
                    "none"),
                default="holm")
            private$..ph_cox <- jmvcore::OptionBool$new(
                "ph_cox",
                ph_cox,
                default=FALSE)
            private$..sc <- jmvcore::OptionBool$new(
                "sc",
                sc,
                default=FALSE)
            private$..kmunicate <- jmvcore::OptionBool$new(
                "kmunicate",
                kmunicate,
                default=FALSE)
            private$..ce <- jmvcore::OptionBool$new(
                "ce",
                ce,
                default=FALSE)
            private$..ch <- jmvcore::OptionBool$new(
                "ch",
                ch,
                default=FALSE)
            private$..endplot <- jmvcore::OptionInteger$new(
                "endplot",
                endplot,
                default=60)
            private$..ybegin_plot <- jmvcore::OptionNumber$new(
                "ybegin_plot",
                ybegin_plot,
                default=0)
            private$..yend_plot <- jmvcore::OptionNumber$new(
                "yend_plot",
                yend_plot,
                default=1)
            private$..byplot <- jmvcore::OptionInteger$new(
                "byplot",
                byplot,
                default=12)
            private$..multievent <- jmvcore::OptionBool$new(
                "multievent",
                multievent,
                default=FALSE)
            private$..ci95 <- jmvcore::OptionBool$new(
                "ci95",
                ci95,
                default=FALSE)
            private$..risktable <- jmvcore::OptionBool$new(
                "risktable",
                risktable,
                default=FALSE)
            private$..censored <- jmvcore::OptionBool$new(
                "censored",
                censored,
                default=FALSE)
            private$..pplot <- jmvcore::OptionBool$new(
                "pplot",
                pplot,
                default=TRUE)

            self$.addOption(private$..elapsedtime)
            self$.addOption(private$..tint)
            self$.addOption(private$..dxdate)
            self$.addOption(private$..fudate)
            self$.addOption(private$..calculatedtime)
            self$.addOption(private$..explanatory)
            self$.addOption(private$..outcome)
            self$.addOption(private$..outcomeLevel)
            self$.addOption(private$..dod)
            self$.addOption(private$..dooc)
            self$.addOption(private$..awd)
            self$.addOption(private$..awod)
            self$.addOption(private$..analysistype)
            self$.addOption(private$..outcomeredifened)
            self$.addOption(private$..cutp)
            self$.addOption(private$..timetypedata)
            self$.addOption(private$..timetypeoutput)
            self$.addOption(private$..uselandmark)
            self$.addOption(private$..landmark)
            self$.addOption(private$..pw)
            self$.addOption(private$..padjustmethod)
            self$.addOption(private$..ph_cox)
            self$.addOption(private$..sc)
            self$.addOption(private$..kmunicate)
            self$.addOption(private$..ce)
            self$.addOption(private$..ch)
            self$.addOption(private$..endplot)
            self$.addOption(private$..ybegin_plot)
            self$.addOption(private$..yend_plot)
            self$.addOption(private$..byplot)
            self$.addOption(private$..multievent)
            self$.addOption(private$..ci95)
            self$.addOption(private$..risktable)
            self$.addOption(private$..censored)
            self$.addOption(private$..pplot)
        }),
    active = list(
        elapsedtime = function() private$..elapsedtime$value,
        tint = function() private$..tint$value,
        dxdate = function() private$..dxdate$value,
        fudate = function() private$..fudate$value,
        calculatedtime = function() private$..calculatedtime$value,
        explanatory = function() private$..explanatory$value,
        outcome = function() private$..outcome$value,
        outcomeLevel = function() private$..outcomeLevel$value,
        dod = function() private$..dod$value,
        dooc = function() private$..dooc$value,
        awd = function() private$..awd$value,
        awod = function() private$..awod$value,
        analysistype = function() private$..analysistype$value,
        outcomeredifened = function() private$..outcomeredifened$value,
        cutp = function() private$..cutp$value,
        timetypedata = function() private$..timetypedata$value,
        timetypeoutput = function() private$..timetypeoutput$value,
        uselandmark = function() private$..uselandmark$value,
        landmark = function() private$..landmark$value,
        pw = function() private$..pw$value,
        padjustmethod = function() private$..padjustmethod$value,
        ph_cox = function() private$..ph_cox$value,
        sc = function() private$..sc$value,
        kmunicate = function() private$..kmunicate$value,
        ce = function() private$..ce$value,
        ch = function() private$..ch$value,
        endplot = function() private$..endplot$value,
        ybegin_plot = function() private$..ybegin_plot$value,
        yend_plot = function() private$..yend_plot$value,
        byplot = function() private$..byplot$value,
        multievent = function() private$..multievent$value,
        ci95 = function() private$..ci95$value,
        risktable = function() private$..risktable$value,
        censored = function() private$..censored$value,
        pplot = function() private$..pplot$value),
    private = list(
        ..elapsedtime = NA,
        ..tint = NA,
        ..dxdate = NA,
        ..fudate = NA,
        ..calculatedtime = NA,
        ..explanatory = NA,
        ..outcome = NA,
        ..outcomeLevel = NA,
        ..dod = NA,
        ..dooc = NA,
        ..awd = NA,
        ..awod = NA,
        ..analysistype = NA,
        ..outcomeredifened = NA,
        ..cutp = NA,
        ..timetypedata = NA,
        ..timetypeoutput = NA,
        ..uselandmark = NA,
        ..landmark = NA,
        ..pw = NA,
        ..padjustmethod = NA,
        ..ph_cox = NA,
        ..sc = NA,
        ..kmunicate = NA,
        ..ce = NA,
        ..ch = NA,
        ..endplot = NA,
        ..ybegin_plot = NA,
        ..yend_plot = NA,
        ..byplot = NA,
        ..multievent = NA,
        ..ci95 = NA,
        ..risktable = NA,
        ..censored = NA,
        ..pplot = NA)
)

survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "survivalResults",
    inherit = jmvcore::Group,
    active = list(
        subtitle = function() private$.items[["subtitle"]],
        todo = function() private$.items[["todo"]],
        medianSummary = function() private$.items[["medianSummary"]],
        medianTable = function() private$.items[["medianTable"]],
        coxSummary = function() private$.items[["coxSummary"]],
        coxTable = function() private$.items[["coxTable"]],
        tCoxtext2 = function() private$.items[["tCoxtext2"]],
        cox_ph = function() private$.items[["cox_ph"]],
        plot8 = function() private$.items[["plot8"]],
        survTableSummary = function() private$.items[["survTableSummary"]],
        survTable = function() private$.items[["survTable"]],
        pairwiseSummary = function() private$.items[["pairwiseSummary"]],
        pairwiseTable = function() private$.items[["pairwiseTable"]],
        plot = function() private$.items[["plot"]],
        plot2 = function() private$.items[["plot2"]],
        plot3 = function() private$.items[["plot3"]],
        plot6 = function() private$.items[["plot6"]],
        calculatedtime = function() private$.items[["calculatedtime"]],
        outcomeredifened = function() private$.items[["outcomeredifened"]]),
    private = list(),
    public=list(
        initialize=function(options) {
            super$initialize(
                options=options,
                name="",
                title="Survival Analysis",
                refs=list(
                    "finalfit",
                    "survival",
                    "survminer",
                    "survivaltutorial",
                    "survivalrwnahhas",
                    "survivalrviews",
                    "appliedsurvivalanalysisR",
                    "ClinicoPathJamoviModule"))
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="subtitle",
                title="`Survival Analysis - ${explanatory}`"))
            self$add(jmvcore::Html$new(
                options=options,
                name="todo",
                title="To Do",
                clearWith=list(
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="medianSummary",
                title="`Median Survival Summary and Table - ${explanatory}`",
                clearWith=list(
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Table$new(
                options=options,
                name="medianTable",
                title="`Median Survival Table: Levels for ${explanatory}`",
                rows=0,
                columns=list(
                    list(
                        `name`="factor", 
                        `title`="Levels", 
                        `type`="text"),
                    list(
                        `name`="records", 
                        `title`="Records", 
                        `type`="integer"),
                    list(
                        `name`="events", 
                        `title`="Events", 
                        `type`="integer"),
                    list(
                        `name`="rmean", 
                        `title`="rmean", 
                        `type`="number"),
                    list(
                        `name`="se_rmean", 
                        `title`="se_rmean", 
                        `type`="number"),
                    list(
                        `name`="median", 
                        `title`="Median", 
                        `type`="number"),
                    list(
                        `name`="x0_95lcl", 
                        `title`="Lower", 
                        `superTitle`="95% Confidence Interval", 
                        `type`="number"),
                    list(
                        `name`="x0_95ucl", 
                        `title`="Upper", 
                        `superTitle`="95% Confidence Interval", 
                        `type`="number")),
                clearWith=list(
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="coxSummary",
                title="`Cox Regression Summary and Table - ${explanatory}`",
                clearWith=list(
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Table$new(
                options=options,
                name="coxTable",
                title="`Cox Table- ${explanatory}`",
                rows=0,
                columns=list(
                    list(
                        `name`="Explanatory", 
                        `title`="Explanatory", 
                        `type`="text"),
                    list(
                        `name`="Levels", 
                        `title`="Levels", 
                        `type`="text"),
                    list(
                        `name`="all", 
                        `title`="all", 
                        `type`="text"),
                    list(
                        `name`="HR_univariable", 
                        `title`="HR (Univariable)", 
                        `type`="text")),
                clearWith=list(
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Html$new(
                options=options,
                name="tCoxtext2",
                title="",
                refs="finalfit",
                clearWith=list(
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent",
                    "contexpl")))
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="cox_ph",
                title="Proportional Hazards Assumption",
                visible="(ph_cox)",
                clearWith=list(
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent",
                    "contexpl")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot8",
                title="`Proportional Hazards Assumption - ${explanatory}`",
                width=600,
                height=450,
                renderFun=".plot8",
                visible="(ph_cox)",
                requiresData=TRUE,
                clearWith=list(
                    "ph_cox",
                    "endplot",
                    "byplot",
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="survTableSummary",
                title="`1, 3, 5-yr Survival Summary and Table  - ${explanatory}`",
                clearWith=list(
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Table$new(
                options=options,
                name="survTable",
                title="`1, 3, 5 year Survival - ${explanatory}`",
                rows=0,
                columns=list(
                    list(
                        `name`="strata", 
                        `title`="Levels", 
                        `type`="text"),
                    list(
                        `name`="time", 
                        `title`="time", 
                        `type`="integer"),
                    list(
                        `name`="n.risk", 
                        `title`="Number at Risk", 
                        `type`="integer"),
                    list(
                        `name`="n.event", 
                        `title`="Number of Events", 
                        `type`="integer"),
                    list(
                        `name`="surv", 
                        `title`="Survival", 
                        `type`="number", 
                        `format`="pc"),
                    list(
                        `name`="lower", 
                        `title`="Lower", 
                        `superTitle`="95% Confidence Interval", 
                        `type`="number", 
                        `format`="pc"),
                    list(
                        `name`="upper", 
                        `title`="Upper", 
                        `superTitle`="95% Confidence Interval", 
                        `type`="number", 
                        `format`="pc")),
                clearWith=list(
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="pairwiseSummary",
                title="`Pairwise Comparison Summary and Table - ${explanatory}`",
                clearWith=list(
                    "pw",
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent"),
                visible="(pw)"))
            self$add(jmvcore::Table$new(
                options=options,
                name="pairwiseTable",
                title="`Pairwise Comparison Table - ${explanatory}`",
                rows=0,
                columns=list(
                    list(
                        `name`="rowname", 
                        `title`="Levels", 
                        `type`="text"),
                    list(
                        `name`="name", 
                        `title`="Levels", 
                        `type`="text"),
                    list(
                        `name`="value", 
                        `title`="p-value", 
                        `type`="number", 
                        `format`="zto,pvalue")),
                visible="(pw)",
                clearWith=list(
                    "pw",
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent"),
                refs=list(
                    "padjust")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot",
                title="`Survival Plot - ${explanatory}`",
                width=600,
                height=450,
                renderFun=".plot",
                visible="(sc)",
                requiresData=TRUE,
                clearWith=list(
                    "sc",
                    "endplot",
                    "byplot",
                    "ybegin_plot",
                    "yend_plot",
                    "ci95",
                    "risktable",
                    "censored",
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent",
                    "pplot")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot2",
                title="`Cumulative Events - ${explanatory}`",
                width=600,
                height=450,
                renderFun=".plot2",
                visible="(ce)",
                requiresData=TRUE,
                clearWith=list(
                    "ce",
                    "endplot",
                    "byplot",
                    "ybegin_plot",
                    "yend_plot",
                    "ci95",
                    "risktable",
                    "censored",
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot3",
                title="`Cumulative Hazard - ${explanatory}`",
                width=600,
                height=450,
                renderFun=".plot3",
                visible="(ch)",
                requiresData=TRUE,
                clearWith=list(
                    "ch",
                    "endplot",
                    "byplot",
                    "ybegin_plot",
                    "yend_plot",
                    "ci95",
                    "risktable",
                    "censored",
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent")))
            self$add(jmvcore::Image$new(
                options=options,
                name="plot6",
                title="`KMunicate-Style Plot - ${explanatory}`",
                width=600,
                height=450,
                renderFun=".plot6",
                visible="(kmunicate)",
                requiresData=TRUE,
                clearWith=list(
                    "kmunicate",
                    "endplot",
                    "byplot",
                    "ybegin_plot",
                    "yend_plot",
                    "explanatory",
                    "outcome",
                    "outcomeLevel",
                    "overalltime",
                    "fudate",
                    "dxdate",
                    "tint",
                    "multievent"),
                refs=list(
                    "KMunicate",
                    "KMunicate2")))
            self$add(jmvcore::Output$new(
                options=options,
                name="calculatedtime",
                title="Add Calculated Time to Data",
                varTitle="`Calculated Time - from ${ dxdate } to { fudate }`",
                varDescription="`Calculated Time from Given Dates - from ${ dxdate } to { fudate } in Survival Analysis`",
                measureType="continuous",
                clearWith=list(
                    "tint",
                    "dxdate",
                    "fudate",
                    "overalltime",
                    "calculatedtime")))
            self$add(jmvcore::Output$new(
                options=options,
                name="outcomeredifened",
                title="Add Redefined Outcome to Data",
                varTitle="`Redefined Outcome - from ${ outcome } for { analysistype } survival analysis`",
                varDescription="Redefined Outcome from Outcome based on Analysis Type in Survival Analysis",
                clearWith=list(
                    "outcome",
                    "analysistype",
                    "multievent",
                    "explanatory",
                    "outcomeLevel")))}))

survivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "survivalBase",
    inherit = jmvcore::Analysis,
    public = list(
        initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
            super$initialize(
                package = "ClinicoPath",
                name = "survival",
                version = c(1,0,0),
                options = options,
                results = survivalResults$new(options=options),
                data = data,
                datasetId = datasetId,
                analysisId = analysisId,
                revision = revision,
                pause = NULL,
                completeWhenFilled = FALSE,
                requiresMissings = FALSE,
                weightsSupport = 'none')
        }))

#' Survival Analysis
#'
#' Function for Generating Summaries for Survival Analysis.
#'
#' @examples
#' # example will be added
#'
#' @param data The data as a data frame.
#' @param elapsedtime .
#' @param tint .
#' @param dxdate .
#' @param fudate .
#' @param explanatory .
#' @param outcome .
#' @param outcomeLevel .
#' @param dod .
#' @param dooc .
#' @param awd .
#' @param awod .
#' @param analysistype .
#' @param cutp .
#' @param timetypedata select the time type in data
#' @param timetypeoutput select the time type in output
#' @param uselandmark .
#' @param landmark .
#' @param pw .
#' @param padjustmethod .
#' @param ph_cox .
#' @param sc .
#' @param kmunicate .
#' @param ce .
#' @param ch .
#' @param endplot .
#' @param ybegin_plot .
#' @param yend_plot .
#' @param byplot .
#' @param multievent .
#' @param ci95 .
#' @param risktable .
#' @param censored .
#' @param pplot .
#' @return A results object containing:
#' \tabular{llllll}{
#'   \code{results$subtitle} \tab \tab \tab \tab \tab a preformatted \cr
#'   \code{results$todo} \tab \tab \tab \tab \tab a html \cr
#'   \code{results$medianSummary} \tab \tab \tab \tab \tab a preformatted \cr
#'   \code{results$medianTable} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$coxSummary} \tab \tab \tab \tab \tab a preformatted \cr
#'   \code{results$coxTable} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$tCoxtext2} \tab \tab \tab \tab \tab a html \cr
#'   \code{results$cox_ph} \tab \tab \tab \tab \tab a preformatted \cr
#'   \code{results$plot8} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$survTableSummary} \tab \tab \tab \tab \tab a preformatted \cr
#'   \code{results$survTable} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$pairwiseSummary} \tab \tab \tab \tab \tab a preformatted \cr
#'   \code{results$pairwiseTable} \tab \tab \tab \tab \tab a table \cr
#'   \code{results$plot} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot2} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot3} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$plot6} \tab \tab \tab \tab \tab an image \cr
#'   \code{results$calculatedtime} \tab \tab \tab \tab \tab an output \cr
#'   \code{results$outcomeredifened} \tab \tab \tab \tab \tab an output \cr
#' }
#'
#' Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example:
#'
#' \code{results$medianTable$asDF}
#'
#' \code{as.data.frame(results$medianTable)}
#'
#' @export
survival <- function(
    data,
    elapsedtime,
    tint = FALSE,
    dxdate,
    fudate,
    explanatory,
    outcome,
    outcomeLevel,
    dod,
    dooc,
    awd,
    awod,
    analysistype = "overall",
    cutp = "12, 36, 60",
    timetypedata = "ymd",
    timetypeoutput = "months",
    uselandmark = FALSE,
    landmark = 3,
    pw = FALSE,
    padjustmethod = "holm",
    ph_cox = FALSE,
    sc = FALSE,
    kmunicate = FALSE,
    ce = FALSE,
    ch = FALSE,
    endplot = 60,
    ybegin_plot = 0,
    yend_plot = 1,
    byplot = 12,
    multievent = FALSE,
    ci95 = FALSE,
    risktable = FALSE,
    censored = FALSE,
    pplot = TRUE) {

    if ( ! requireNamespace("jmvcore", quietly=TRUE))
        stop("survival requires jmvcore to be installed (restart may be required)")

    if ( ! missing(elapsedtime)) elapsedtime <- jmvcore::resolveQuo(jmvcore::enquo(elapsedtime))
    if ( ! missing(dxdate)) dxdate <- jmvcore::resolveQuo(jmvcore::enquo(dxdate))
    if ( ! missing(fudate)) fudate <- jmvcore::resolveQuo(jmvcore::enquo(fudate))
    if ( ! missing(explanatory)) explanatory <- jmvcore::resolveQuo(jmvcore::enquo(explanatory))
    if ( ! missing(outcome)) outcome <- jmvcore::resolveQuo(jmvcore::enquo(outcome))
    if (missing(data))
        data <- jmvcore::marshalData(
            parent.frame(),
            `if`( ! missing(elapsedtime), elapsedtime, NULL),
            `if`( ! missing(dxdate), dxdate, NULL),
            `if`( ! missing(fudate), fudate, NULL),
            `if`( ! missing(explanatory), explanatory, NULL),
            `if`( ! missing(outcome), outcome, NULL))

    for (v in explanatory) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])

    options <- survivalOptions$new(
        elapsedtime = elapsedtime,
        tint = tint,
        dxdate = dxdate,
        fudate = fudate,
        explanatory = explanatory,
        outcome = outcome,
        outcomeLevel = outcomeLevel,
        dod = dod,
        dooc = dooc,
        awd = awd,
        awod = awod,
        analysistype = analysistype,
        cutp = cutp,
        timetypedata = timetypedata,
        timetypeoutput = timetypeoutput,
        uselandmark = uselandmark,
        landmark = landmark,
        pw = pw,
        padjustmethod = padjustmethod,
        ph_cox = ph_cox,
        sc = sc,
        kmunicate = kmunicate,
        ce = ce,
        ch = ch,
        endplot = endplot,
        ybegin_plot = ybegin_plot,
        yend_plot = yend_plot,
        byplot = byplot,
        multievent = multievent,
        ci95 = ci95,
        risktable = risktable,
        censored = censored,
        pplot = pplot)

    analysis <- survivalClass$new(
        options = options,
        data = data)

    analysis$run()

    analysis$results
}