# This file is automatically generated, you probably don't want to edit this
twoproportionsOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
"twoproportionsOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
dep = NULL,
group = NULL,
eventcode = 1,
ciWidth = 95, ...) {
super$initialize(
package='EstimationStats',
name='twoproportions',
requiresData=TRUE,
...)
private$..dep <- jmvcore::OptionVariable$new(
"dep",
dep,
rejectInf=TRUE)
private$..group <- jmvcore::OptionVariable$new(
"group",
group,
rejectInf=TRUE)
private$..eventcode <- jmvcore::OptionInteger$new(
"eventcode",
eventcode,
default=1,
min=1,
max=2)
private$..ciWidth <- jmvcore::OptionNumber$new(
"ciWidth",
ciWidth,
min=50,
max=99.9,
default=95)
self$.addOption(private$..dep)
self$.addOption(private$..group)
self$.addOption(private$..eventcode)
self$.addOption(private$..ciWidth)
}),
active = list(
dep = function() private$..dep$value,
group = function() private$..group$value,
eventcode = function() private$..eventcode$value,
ciWidth = function() private$..ciWidth$value),
private = list(
..dep = NA,
..group = NA,
..eventcode = NA,
..ciWidth = NA)
)
twoproportionsResults <- if (requireNamespace('jmvcore')) R6::R6Class(
inherit = jmvcore::Group,
active = list(
propd = function() private$.items[["propd"]],
text = function() private$.items[["text"]],
plot = function() private$.items[["plot"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Difference between two proportions")
self$add(jmvcore::Table$new(
options=options,
name="propd",
title="Table of results",
rows=3,
columns=list(
list(
`name`="Group",
`type`="text"),
list(
`name`="r_n",
`title`="r / N",
`type`="text"),
list(
`name`="P",
`type`="number"),
list(
`name`="CI_low",
`type`="number"),
list(
`name`="CI_high",
`type`="number",
`format`="zto"))))
self$add(jmvcore::Preformatted$new(
options=options,
name="text"))
self$add(jmvcore::Image$new(
options=options,
name="plot",
title="Difference Plot",
width=400,
height=300,
renderFun=".plot"))}))
twoproportionsBase <- if (requireNamespace('jmvcore')) R6::R6Class(
"twoproportionsBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = 'EstimationStats',
name = 'twoproportions',
version = c(1,0,0),
options = options,
results = twoproportionsResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE)
}))
#' Difference between two proportions
#'
#'
#' @param data .
#' @param dep .
#' @param group .
#' @param eventcode .
#' @param ciWidth .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$propd} \tab \tab \tab \tab \tab a table \cr
#' \code{results$text} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$plot} \tab \tab \tab \tab \tab an image \cr
#' }
#'
#' Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example:
#'
#' \code{results$propd$asDF}
#'
#' \code{as.data.frame(results$propd)}
#'
#' @export
twoproportions <- function(
data,
dep,
group,
eventcode = 1,
ciWidth = 95) {
if ( ! requireNamespace('jmvcore'))
stop('twoproportions requires jmvcore to be installed (restart may be required)')
options <- twoproportionsOptions$new(
dep = dep,
group = group,
eventcode = eventcode,
ciWidth = ciWidth)
results <- twoproportionsResults$new(
options = options)
analysis <- twoproportionsClass$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.