# This file is automatically generated, you probably don't want to edit this
ciSingleOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"ciSingleOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
deps = NULL,
splitBy = NULL,
ciWidth = 95, ...) {
super$initialize(
package="ClinicoPath",
name="ciSingle",
requiresData=TRUE,
...)
private$..deps <- jmvcore::OptionVariables$new(
"deps",
deps,
suggested=list(
"continuous"),
permitted=list(
"numeric"))
private$..splitBy <- jmvcore::OptionVariable$new(
"splitBy",
splitBy,
suggested=list(
"nominal"),
permitted=list(
"factor"))
private$..ciWidth <- jmvcore::OptionNumber$new(
"ciWidth",
ciWidth,
default=95,
min=50,
max=99.99)
self$.addOption(private$..deps)
self$.addOption(private$..splitBy)
self$.addOption(private$..ciWidth)
}),
active = list(
deps = function() private$..deps$value,
splitBy = function() private$..splitBy$value,
ciWidth = function() private$..ciWidth$value),
private = list(
..deps = NA,
..splitBy = NA,
..ciWidth = NA)
)
ciSingleResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"ciSingleResults",
inherit = jmvcore::Group,
active = list(
conflevel = function() private$.items[["conflevel"]],
citable = function() private$.items[["citable"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Confidence interval for a mean")
self$add(jmvcore::Preformatted$new(
options=options,
name="conflevel",
title=""))
self$add(jmvcore::Table$new(
options=options,
name="citable",
title="Confidence interval for a mean",
rows="(deps)",
columns=list(
list(
`name`="var",
`title`="",
`type`="text"),
list(
`name`="mean",
`title`="Mean",
`type`="number"),
list(
`name`="lb",
`title`="Lower bound",
`type`="number"),
list(
`name`="ub",
`title`="Upper bound",
`type`="number"))))}))
ciSingleBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"ciSingleBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "ClinicoPath",
name = "ciSingle",
version = c(1,0,0),
options = options,
results = ciSingleResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Confidence interval for a mean
#'
#'
#' @param data .
#' @param deps .
#' @param splitBy .
#' @param ciWidth .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$conflevel} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$citable} \tab \tab \tab \tab \tab a table \cr
#' }
#'
#' Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example:
#'
#' \code{results$citable$asDF}
#'
#' \code{as.data.frame(results$citable)}
#'
#' @export
ciSingle <- function(
data,
deps,
splitBy,
ciWidth = 95) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("ciSingle requires jmvcore to be installed (restart may be required)")
if ( ! missing(deps)) deps <- jmvcore::resolveQuo(jmvcore::enquo(deps))
if ( ! missing(splitBy)) splitBy <- jmvcore::resolveQuo(jmvcore::enquo(splitBy))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(deps), deps, NULL),
`if`( ! missing(splitBy), splitBy, NULL))
for (v in splitBy) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
options <- ciSingleOptions$new(
deps = deps,
splitBy = splitBy,
ciWidth = ciWidth)
analysis <- ciSingleClass$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.