# This file is automatically generated, you probably don't want to edit this
descfreqOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"descfreqOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
rows = NULL,
columns = NULL,
tuto = TRUE,
threshold = 5, ...) {
super$initialize(
package="MEDA",
name="descfreq",
requiresData=TRUE,
...)
private$..rows <- jmvcore::OptionVariable$new(
"rows",
rows,
suggested=list(
"nominal"),
permitted=list(
"factor"))
private$..columns <- jmvcore::OptionVariables$new(
"columns",
columns,
suggested=list(
"continuous"),
permitted=list(
"numeric"))
private$..tuto <- jmvcore::OptionBool$new(
"tuto",
tuto,
default=TRUE)
private$..threshold <- jmvcore::OptionNumber$new(
"threshold",
threshold,
default=5)
self$.addOption(private$..rows)
self$.addOption(private$..columns)
self$.addOption(private$..tuto)
self$.addOption(private$..threshold)
}),
active = list(
rows = function() private$..rows$value,
columns = function() private$..columns$value,
tuto = function() private$..tuto$value,
threshold = function() private$..threshold$value),
private = list(
..rows = NA,
..columns = NA,
..tuto = NA,
..threshold = NA)
)
descfreqResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"descfreqResults",
inherit = jmvcore::Group,
active = list(
instructions = function() private$.items[["instructions"]],
descoftablerow = function() private$.items[["descoftablerow"]],
descoftablecol = function() private$.items[["descoftablecol"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Description of the Contingency Table",
refs=list(
"factominer",
"explo"))
self$add(jmvcore::Html$new(
options=options,
name="instructions",
title="Instructions",
visible="(tuto)"))
self$add(jmvcore::Table$new(
options=options,
name="descoftablerow",
title="Description of the Rows",
visible="(rows)",
columns=list(
list(
`name`="mod",
`title`="",
`type`="text",
`combineBelow`=TRUE),
list(
`name`="rowcol",
`title`="",
`type`="text"),
list(
`name`="intern",
`title`="Intern %",
`type`="number"),
list(
`name`="glob",
`title`="Glob %",
`type`="number"),
list(
`name`="intfreq",
`title`="Intern freq",
`type`="number"),
list(
`name`="globfreq",
`title`="Glob freq",
`type`="number"),
list(
`name`="pvalue",
`title`="p",
`type`="number",
`format`="zto,pvalue"),
list(
`name`="vtest",
`title`="v.test",
`type`="number"))))
self$add(jmvcore::Table$new(
options=options,
name="descoftablecol",
title="Description of the Columns",
visible="(rows)",
columns=list(
list(
`name`="mod",
`title`="",
`type`="text",
`combineBelow`=TRUE),
list(
`name`="rowcol",
`title`="",
`type`="text"),
list(
`name`="intern",
`title`="Intern %",
`type`="number"),
list(
`name`="glob",
`title`="Glob %",
`type`="number"),
list(
`name`="intfreq",
`title`="Intern freq",
`type`="number"),
list(
`name`="globfreq",
`title`="Glob freq",
`type`="number"),
list(
`name`="pvalue",
`title`="p",
`type`="number",
`format`="zto,pvalue"),
list(
`name`="vtest",
`title`="v.test",
`type`="number"))))}))
descfreqBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"descfreqBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "MEDA",
name = "descfreq",
version = c(1,0,0),
options = options,
results = descfreqResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Description of a Contingency Table
#'
#'
#' @param data .
#' @param rows .
#' @param columns .
#' @param tuto .
#' @param threshold .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$instructions} \tab \tab \tab \tab \tab a html \cr
#' \code{results$descoftablerow} \tab \tab \tab \tab \tab a table \cr
#' \code{results$descoftablecol} \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$descoftablerow$asDF}
#'
#' \code{as.data.frame(results$descoftablerow)}
#'
#' @export
descfreq <- function(
data,
rows,
columns,
tuto = TRUE,
threshold = 5) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("descfreq requires jmvcore to be installed (restart may be required)")
if ( ! missing(rows)) rows <- jmvcore::resolveQuo(jmvcore::enquo(rows))
if ( ! missing(columns)) columns <- jmvcore::resolveQuo(jmvcore::enquo(columns))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(rows), rows, NULL),
`if`( ! missing(columns), columns, NULL))
for (v in rows) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
options <- descfreqOptions$new(
rows = rows,
columns = columns,
tuto = tuto,
threshold = threshold)
analysis <- descfreqClass$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.