# This file is automatically generated, you probably don't want to edit this
singleOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
"singleOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
variable = NULL, ...) {
super$initialize(
package='Statkat',
name='single',
requiresData=TRUE,
...)
private$..variable <- jmvcore::OptionVariable$new(
"variable",
variable)
self$.addOption(private$..variable)
}),
active = list(
variable = function() private$..variable$value),
private = list(
..variable = NA)
)
singleResults <- if (requireNamespace('jmvcore')) R6::R6Class(
inherit = jmvcore::Group,
active = list(
advice = function() private$.items[["advice"]],
plot = function() private$.items[["plot"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Single Variable")
self$add(jmvcore::Html$new(
options=options,
name="advice",
title="Advice",
visible="(text)"))
self$add(jmvcore::Image$new(
options=options,
name="plot",
title="Scatter Plot",
width=400,
height=300,
requiresData=TRUE,
renderFun=".plot"))}))
singleBase <- if (requireNamespace('jmvcore')) R6::R6Class(
"singleBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = 'Statkat',
name = 'single',
version = c(1,0,0),
options = options,
results = singleResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE)
}))
#' Single Variable
#'
#' Provides a recommended statistical method given the measurement level of
#' your data. Appropriate when you are interested in a single variable.
#'
#' @examples
#' exampleData <- data.frame(x1 = rnorm(20),
#' x2 = as.factor(c(rep(1, 10), rep(2, 10))),
#' x3 = as.ordered(c(rep(1, 10), rep(2, 5), rep(3, 5))))
#'
#' single(exampleData, variable = 'x1')
#' single(exampleData, variable = 'x2')
#' single(exampleData, variable = 'x3')
#'
#' @param data the data as a data frame, with variables encoded as numeric
#' (for interval/ratio variables), ordered (for ordinal variables), or factor
#' (for nominal variables)
#' @param variable a string naming a variable from \code{data}
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$advice} \tab \tab \tab \tab \tab the method recommendation \cr
#' \code{results$plot} \tab \tab \tab \tab \tab a scatter plot of the data \cr
#' }
#'
#' @export
single <- function(
data,
variable) {
if ( ! requireNamespace('jmvcore'))
stop('single requires jmvcore to be installed (restart may be required)')
options <- singleOptions$new(
variable = variable)
results <- singleResults$new(
options = options)
analysis <- singleClass$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.