# This file is automatically generated, you probably don't want to edit this
reportcatOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"reportcatOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
vars = NULL, ...) {
super$initialize(
package="ClinicoPath",
name="reportcat",
requiresData=TRUE,
...)
private$..vars <- jmvcore::OptionVariables$new(
"vars",
vars,
suggested=list(
"ordinal",
"nominal"),
permitted=list(
"factor"))
self$.addOption(private$..vars)
}),
active = list(
vars = function() private$..vars$value),
private = list(
..vars = NA)
)
reportcatResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"reportcatResults",
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 Categorical Variables",
refs=list(
"report",
"gtExtras",
"ClinicoPathJamoviModule"))
self$add(jmvcore::Html$new(
options=options,
name="todo",
title="To Do",
clearWith=list(
"vars")))
self$add(jmvcore::Html$new(
options=options,
name="text",
title=""))
self$add(jmvcore::Html$new(
options=options,
name="text1",
title="Categorical Data"))}))
reportcatBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"reportcatBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "ClinicoPath",
name = "reportcat",
version = c(0,0,2),
options = options,
results = reportcatResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Summary of Categorical Variables
#'
#' Generates a detailed summary of categorical variables including counts,
#' percentages, and missing value information. The output is presented in both
#' textual and visual formats, making it easy to interpret the distribution of
#' your data.
#'
#'
#' @examples
#' \donttest{
#' # Example usage:
#' # 1. Load your data into a data frame.
#' # 2. Select the categorical variables to summarize.
#' # 3. Run the reportcat module to view the summary.
#' #
#' # The module will produce a styled textual report along with a visual summary table.
#'}
#' @param data The data as a data frame.
#' @param vars Select the variables from your data frame that you wish to
#' summarize. Only categorical variables (nominal, ordinal, or factors) are
#' allowed.
#' @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 html \cr
#' \code{results$text1} \tab \tab \tab \tab \tab a html \cr
#' }
#'
#' @export
reportcat <- function(
data,
vars) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("reportcat 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))
for (v in vars) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
options <- reportcatOptions$new(
vars = vars)
analysis <- reportcatClass$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.