# This file is automatically generated, you probably don't want to edit this
agepyramidOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"agepyramidOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
age = NULL,
gender = NULL,
female = NULL, ...) {
super$initialize(
package="ClinicoPathLinuxDescriptives",
name="agepyramid",
requiresData=TRUE,
...)
private$..age <- jmvcore::OptionVariable$new(
"age",
age,
suggested=list(
"continuous"),
permitted=list(
"numeric"))
private$..gender <- jmvcore::OptionVariable$new(
"gender",
gender,
suggested=list(
"ordinal",
"nominal"),
permitted=list(
"factor"))
private$..female <- jmvcore::OptionLevel$new(
"female",
female,
variable="(gender)")
self$.addOption(private$..age)
self$.addOption(private$..gender)
self$.addOption(private$..female)
}),
active = list(
age = function() private$..age$value,
gender = function() private$..gender$value,
female = function() private$..female$value),
private = list(
..age = NA,
..gender = NA,
..female = NA)
)
agepyramidResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"agepyramidResults",
inherit = jmvcore::Group,
active = list(
pyramidTable = function() private$.items[["pyramidTable"]],
plot = function() private$.items[["plot"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Age Pyramid",
refs=list(
"ClinicoPathJamoviModule"))
self$add(jmvcore::Table$new(
options=options,
name="pyramidTable",
title="Population Data",
rows=0,
columns=list(
list(
`name`="Pop",
`title`="Population",
`type`="text"),
list(
`name`="Female",
`title`="Female",
`type`="number"),
list(
`name`="Male",
`title`="Male",
`type`="number")),
clearWith=list(
"age",
"gender",
"female")))
self$add(jmvcore::Image$new(
options=options,
name="plot",
title="Age Pyramid",
width=600,
height=450,
renderFun=".plot",
requiresData=TRUE,
clearWith=list(
"age",
"gender",
"female")))}))
agepyramidBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"agepyramidBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "ClinicoPathLinuxDescriptives",
name = "agepyramid",
version = c(1,0,0),
options = options,
results = agepyramidResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Age Pyramid
#'
#'
#' @param data The data as a data frame.
#' @param age .
#' @param gender .
#' @param female .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$pyramidTable} \tab \tab \tab \tab \tab a table \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$pyramidTable$asDF}
#'
#' \code{as.data.frame(results$pyramidTable)}
#'
#' @export
agepyramid <- function(
data,
age,
gender,
female) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("agepyramid requires jmvcore to be installed (restart may be required)")
if ( ! missing(age)) age <- jmvcore::resolveQuo(jmvcore::enquo(age))
if ( ! missing(gender)) gender <- jmvcore::resolveQuo(jmvcore::enquo(gender))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(age), age, NULL),
`if`( ! missing(gender), gender, NULL))
for (v in gender) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
options <- agepyramidOptions$new(
age = age,
gender = gender,
female = female)
analysis <- agepyramidClass$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.