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

summarydataOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "summarydataOptions",
    inherit = jmvcore::Options,
    public = list(
        initialize = function(
            vars = NULL, ...) {

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

            private$..vars <- jmvcore::OptionVariables$new(
                "vars",
                vars,
                suggested=list(
                    "continuous"),
                permitted=list(
                    "numeric"))

            self$.addOption(private$..vars)
        }),
    active = list(
        vars = function() private$..vars$value),
    private = list(
        ..vars = NA)
)

summarydataResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "summarydataResults",
    inherit = jmvcore::Group,
    active = list(
        todo = function() private$.items[["todo"]],
        text = function() private$.items[["text"]],
        text1 = function() private$.items[["text1"]]),
    private = list(),
    public=list(
        initialize=function(options) {
            super$initialize(
                options=options,
                name="",
                title="Summary of Continuous Variables",
                refs=list(
                    "gtExtras",
                    "ClinicoPathJamoviModule"))
            self$add(jmvcore::Html$new(
                options=options,
                name="todo",
                title="To Do"))
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="text",
                title=""))
            self$add(jmvcore::Html$new(
                options=options,
                name="text1",
                title="Continuous Data Plots"))}))

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

#' Summary of Continuous Variables
#'
#' Function for Generating Summaries for Continuous Variables.
#'
#' @examples
#' \dontrun{
#' # example will be added
#'}
#' @param data The data as a data frame.
#' @param vars a string naming the variables from \code{data} that contains
#'   the continuous values used for the report
#' @return A results object containing:
#' \tabular{llllll}{
#'   \code{results$todo} \tab \tab \tab \tab \tab a html \cr
#'   \code{results$text} \tab \tab \tab \tab \tab a preformatted \cr
#'   \code{results$text1} \tab \tab \tab \tab \tab a html \cr
#' }
#'
#' @export
summarydata <- function(
    data,
    vars) {

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

    if ( ! missing(vars)) vars <- jmvcore::resolveQuo(jmvcore::enquo(vars))
    if (missing(data))
        data <- jmvcore::marshalData(
            parent.frame(),
            `if`( ! missing(vars), vars, NULL))


    options <- summarydataOptions$new(
        vars = vars)

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

    analysis$run()

    analysis$results
}

