# This file is automatically generated, you probably don't want to edit this
tidyplotsOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"tidyplotsOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
xvar = NULL,
yvar = NULL,
color = NULL,
plotType = "points",
pointType = "basic",
showMean = FALSE,
showSEM = FALSE,
showCI = FALSE,
colorScheme = "friendly",
plotTitle = "",
xLabel = "",
yLabel = "", ...) {
super$initialize(
package="ClinicoPath",
name="tidyplots",
requiresData=TRUE,
...)
private$..xvar <- jmvcore::OptionVariable$new(
"xvar",
xvar)
private$..yvar <- jmvcore::OptionVariable$new(
"yvar",
yvar)
private$..color <- jmvcore::OptionVariable$new(
"color",
color)
private$..plotType <- jmvcore::OptionList$new(
"plotType",
plotType,
options=list(
"points",
"line",
"bar",
"boxplot"),
default="points")
private$..pointType <- jmvcore::OptionList$new(
"pointType",
pointType,
options=list(
"basic",
"beeswarm",
"jitter"),
default="basic")
private$..showMean <- jmvcore::OptionBool$new(
"showMean",
showMean,
default=FALSE)
private$..showSEM <- jmvcore::OptionBool$new(
"showSEM",
showSEM,
default=FALSE)
private$..showCI <- jmvcore::OptionBool$new(
"showCI",
showCI,
default=FALSE)
private$..colorScheme <- jmvcore::OptionList$new(
"colorScheme",
colorScheme,
options=list(
"friendly",
"viridis",
"seaside"),
default="friendly")
private$..plotTitle <- jmvcore::OptionString$new(
"plotTitle",
plotTitle,
default="")
private$..xLabel <- jmvcore::OptionString$new(
"xLabel",
xLabel,
default="")
private$..yLabel <- jmvcore::OptionString$new(
"yLabel",
yLabel,
default="")
self$.addOption(private$..xvar)
self$.addOption(private$..yvar)
self$.addOption(private$..color)
self$.addOption(private$..plotType)
self$.addOption(private$..pointType)
self$.addOption(private$..showMean)
self$.addOption(private$..showSEM)
self$.addOption(private$..showCI)
self$.addOption(private$..colorScheme)
self$.addOption(private$..plotTitle)
self$.addOption(private$..xLabel)
self$.addOption(private$..yLabel)
}),
active = list(
xvar = function() private$..xvar$value,
yvar = function() private$..yvar$value,
color = function() private$..color$value,
plotType = function() private$..plotType$value,
pointType = function() private$..pointType$value,
showMean = function() private$..showMean$value,
showSEM = function() private$..showSEM$value,
showCI = function() private$..showCI$value,
colorScheme = function() private$..colorScheme$value,
plotTitle = function() private$..plotTitle$value,
xLabel = function() private$..xLabel$value,
yLabel = function() private$..yLabel$value),
private = list(
..xvar = NA,
..yvar = NA,
..color = NA,
..plotType = NA,
..pointType = NA,
..showMean = NA,
..showSEM = NA,
..showCI = NA,
..colorScheme = NA,
..plotTitle = NA,
..xLabel = NA,
..yLabel = NA)
)
tidyplotsResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"tidyplotsResults",
inherit = jmvcore::Group,
active = list(
instructions = function() private$.items[["instructions"]],
plot = function() private$.items[["plot"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Tidy Plots",
refs=list(
"tidyplots",
"ggplot2",
"dplyr",
"rlang",
"jmvcore",
"R6"))
self$add(jmvcore::Html$new(
options=options,
name="instructions",
title="Instructions",
visible="(xvar === null || yvar === null)"))
self$add(jmvcore::Image$new(
options=options,
name="plot",
title="Plot",
renderFun=".plot",
requiresData=TRUE,
width=600,
height=400,
clearWith=list(
"xvar",
"yvar",
"color",
"plotType",
"pointType",
"showMean",
"showSEM",
"showCI",
"colorScheme",
"plotTitle",
"xLabel",
"yLabel")))}))
tidyplotsBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"tidyplotsBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "ClinicoPath",
name = "tidyplots",
version = c(1,0,0),
options = options,
results = tidyplotsResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Tidy Plots
#'
#'
#' @param data The data as a data frame.
#' @param xvar .
#' @param yvar .
#' @param color .
#' @param plotType .
#' @param pointType .
#' @param showMean .
#' @param showSEM .
#' @param showCI .
#' @param colorScheme .
#' @param plotTitle .
#' @param xLabel .
#' @param yLabel .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$instructions} \tab \tab \tab \tab \tab a html \cr
#' \code{results$plot} \tab \tab \tab \tab \tab an image \cr
#' }
#'
#' @export
tidyplots <- function(
data,
xvar,
yvar,
color,
plotType = "points",
pointType = "basic",
showMean = FALSE,
showSEM = FALSE,
showCI = FALSE,
colorScheme = "friendly",
plotTitle = "",
xLabel = "",
yLabel = "") {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("tidyplots requires jmvcore to be installed (restart may be required)")
if ( ! missing(xvar)) xvar <- jmvcore::resolveQuo(jmvcore::enquo(xvar))
if ( ! missing(yvar)) yvar <- jmvcore::resolveQuo(jmvcore::enquo(yvar))
if ( ! missing(color)) color <- jmvcore::resolveQuo(jmvcore::enquo(color))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(xvar), xvar, NULL),
`if`( ! missing(yvar), yvar, NULL),
`if`( ! missing(color), color, NULL))
options <- tidyplotsOptions$new(
xvar = xvar,
yvar = yvar,
color = color,
plotType = plotType,
pointType = pointType,
showMean = showMean,
showSEM = showSEM,
showCI = showCI,
colorScheme = colorScheme,
plotTitle = plotTitle,
xLabel = xLabel,
yLabel = yLabel)
analysis <- tidyplotsClass$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.