# This file is automatically generated, you probably don't want to edit this
survivalOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
"survivalOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
explanatory = NULL,
overalltime = NULL,
outcome = NULL,
cutp = "12, 36, 60",
sc = FALSE,
ce = FALSE,
ch = FALSE, ...) {
super$initialize(
package='ClinicoPath',
name='survival',
requiresData=TRUE,
...)
private$..explanatory <- jmvcore::OptionVariable$new(
"explanatory",
explanatory,
suggested=list(
"ordinal",
"nominal"),
permitted=list(
"factor"))
private$..overalltime <- jmvcore::OptionVariable$new(
"overalltime",
overalltime,
suggested=list(
"continuous"),
permitted=list(
"numeric"))
private$..outcome <- jmvcore::OptionVariable$new(
"outcome",
outcome,
suggested=list(
"continuous"),
permitted=list(
"numeric"))
private$..cutp <- jmvcore::OptionString$new(
"cutp",
cutp,
default="12, 36, 60")
private$..sc <- jmvcore::OptionBool$new(
"sc",
sc,
default=FALSE)
private$..ce <- jmvcore::OptionBool$new(
"ce",
ce,
default=FALSE)
private$..ch <- jmvcore::OptionBool$new(
"ch",
ch,
default=FALSE)
self$.addOption(private$..explanatory)
self$.addOption(private$..overalltime)
self$.addOption(private$..outcome)
self$.addOption(private$..cutp)
self$.addOption(private$..sc)
self$.addOption(private$..ce)
self$.addOption(private$..ch)
}),
active = list(
explanatory = function() private$..explanatory$value,
overalltime = function() private$..overalltime$value,
outcome = function() private$..outcome$value,
cutp = function() private$..cutp$value,
sc = function() private$..sc$value,
ce = function() private$..ce$value,
ch = function() private$..ch$value),
private = list(
..explanatory = NA,
..overalltime = NA,
..outcome = NA,
..cutp = NA,
..sc = NA,
..ce = NA,
..ch = NA)
)
survivalResults <- if (requireNamespace('jmvcore')) R6::R6Class(
inherit = jmvcore::Group,
active = list(
todo = function() private$.items[["todo"]],
text2 = function() private$.items[["text2"]],
text1html = function() private$.items[["text1html"]],
text5 = function() private$.items[["text5"]],
text4 = function() private$.items[["text4"]],
text7 = function() private$.items[["text7"]],
text6 = function() private$.items[["text6"]],
text8 = function() private$.items[["text8"]],
text9 = function() private$.items[["text9"]],
plot = function() private$.items[["plot"]],
plot2 = function() private$.items[["plot2"]],
plot3 = function() private$.items[["plot3"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="`Survival Analysis - ${explanatory}`",
refs=list(
"finalfit",
"survival",
"survminer"))
self$add(jmvcore::Html$new(
options=options,
name="todo",
title="To Do",
clearWith=list(
"explanatory",
"outcome",
"overalltime")))
self$add(jmvcore::Preformatted$new(
options=options,
name="text2",
title="`Median Survival Summary and Table - ${explanatory}`",
clearWith=list(
"explanatory",
"outcome",
"overalltime")))
self$add(jmvcore::Html$new(
options=options,
name="text1html",
title="`Median Survival Table - ${explanatory}`",
clearWith=list(
"explanatory",
"outcome",
"overalltime")))
self$add(jmvcore::Preformatted$new(
options=options,
name="text5",
title="`Cox Regression Summary and Table - ${explanatory}`",
clearWith=list(
"explanatory",
"outcome",
"overalltime")))
self$add(jmvcore::Html$new(
options=options,
name="text4",
title="`Cox Table- ${explanatory}`",
clearWith=list(
"explanatory",
"outcome",
"overalltime")))
self$add(jmvcore::Preformatted$new(
options=options,
name="text7",
title="`1, 3, 5-yr Survival Summary and Table - ${explanatory}`",
clearWith=list(
"explanatory",
"outcome",
"overalltime")))
self$add(jmvcore::Html$new(
options=options,
name="text6",
title="`1, 3, 5-yr Survival - ${explanatory}`",
clearWith=list(
"explanatory",
"outcome",
"overalltime")))
self$add(jmvcore::Preformatted$new(
options=options,
name="text8",
title="`Pairwise Comparison - ${explanatory}`",
clearWith=list(
"explanatory",
"outcome",
"overalltime")))
self$add(jmvcore::Preformatted$new(
options=options,
name="text9",
title="`Pairwise Comparison Summary - ${explanatory}`",
clearWith=list(
"explanatory",
"outcome",
"overalltime")))
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",
"explanatory",
"outcome",
"overalltime")))
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",
"explanatory",
"outcome",
"overalltime")))
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",
"explanatory",
"outcome",
"overalltime")))}))
survivalBase <- if (requireNamespace('jmvcore')) 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)
}))
#' Survival Analysis
#'
#' Function for Generating Summaries for Survival Analysis.
#'
#' @examples
#' \dontrun{
#' # example will be added
#'}
#' @param data The data as a data frame.
#' @param explanatory .
#' @param overalltime .
#' @param outcome .
#' @param cutp .
#' @param sc .
#' @param ce .
#' @param ch .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$todo} \tab \tab \tab \tab \tab a html \cr
#' \code{results$text2} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$text1html} \tab \tab \tab \tab \tab a html \cr
#' \code{results$text5} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$text4} \tab \tab \tab \tab \tab a html \cr
#' \code{results$text7} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$text6} \tab \tab \tab \tab \tab a html \cr
#' \code{results$text8} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$text9} \tab \tab \tab \tab \tab a preformatted \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
#' }
#'
#' @export
survival <- function(
data,
explanatory,
overalltime,
outcome,
cutp = "12, 36, 60",
sc = FALSE,
ce = FALSE,
ch = FALSE) {
if ( ! requireNamespace('jmvcore'))
stop('survival requires jmvcore to be installed (restart may be required)')
if ( ! missing(explanatory)) explanatory <- jmvcore::resolveQuo(jmvcore::enquo(explanatory))
if ( ! missing(overalltime)) overalltime <- jmvcore::resolveQuo(jmvcore::enquo(overalltime))
if ( ! missing(outcome)) outcome <- jmvcore::resolveQuo(jmvcore::enquo(outcome))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(explanatory), explanatory, NULL),
`if`( ! missing(overalltime), overalltime, NULL),
`if`( ! missing(outcome), outcome, NULL))
for (v in explanatory) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
options <- survivalOptions$new(
explanatory = explanatory,
overalltime = overalltime,
outcome = outcome,
cutp = cutp,
sc = sc,
ce = ce,
ch = ch)
analysis <- survivalClass$new(
options = options,
data = data)
analysis$run()
analysis$results
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.