# This file is automatically generated, you probably don't want to edit this
rankOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"rankOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
vars = NULL,
type = "spearman",
scale = "raw",
cor = TRUE,
plot = FALSE,
plot1 = FALSE,
plot2 = FALSE,
plot3 = FALSE,
width = 500,
height = 500,
width1 = 500,
height1 = 500,
width3 = 500,
height3 = 500,
width2 = 500,
height2 = 500, ...) {
super$initialize(
package="seolmatrix",
name="rank",
requiresData=TRUE,
...)
private$..vars <- jmvcore::OptionVariables$new(
"vars",
vars,
suggested=list(
"nominal",
"ordinal"),
permitted=list(
"factor"))
private$..type <- jmvcore::OptionList$new(
"type",
type,
options=list(
"spearman",
"polychoric",
"tetrachoric"),
default="spearman")
private$..scale <- jmvcore::OptionList$new(
"scale",
scale,
options=list(
"raw",
"z-scores",
"relative"),
default="raw")
private$..cor <- jmvcore::OptionBool$new(
"cor",
cor,
default=TRUE)
private$..plot <- jmvcore::OptionBool$new(
"plot",
plot,
default=FALSE)
private$..plot1 <- jmvcore::OptionBool$new(
"plot1",
plot1,
default=FALSE)
private$..plot2 <- jmvcore::OptionBool$new(
"plot2",
plot2,
default=FALSE)
private$..plot3 <- jmvcore::OptionBool$new(
"plot3",
plot3,
default=FALSE)
private$..width <- jmvcore::OptionInteger$new(
"width",
width,
default=500)
private$..height <- jmvcore::OptionInteger$new(
"height",
height,
default=500)
private$..width1 <- jmvcore::OptionInteger$new(
"width1",
width1,
default=500)
private$..height1 <- jmvcore::OptionInteger$new(
"height1",
height1,
default=500)
private$..width3 <- jmvcore::OptionInteger$new(
"width3",
width3,
default=500)
private$..height3 <- jmvcore::OptionInteger$new(
"height3",
height3,
default=500)
private$..width2 <- jmvcore::OptionInteger$new(
"width2",
width2,
default=500)
private$..height2 <- jmvcore::OptionInteger$new(
"height2",
height2,
default=500)
self$.addOption(private$..vars)
self$.addOption(private$..type)
self$.addOption(private$..scale)
self$.addOption(private$..cor)
self$.addOption(private$..plot)
self$.addOption(private$..plot1)
self$.addOption(private$..plot2)
self$.addOption(private$..plot3)
self$.addOption(private$..width)
self$.addOption(private$..height)
self$.addOption(private$..width1)
self$.addOption(private$..height1)
self$.addOption(private$..width3)
self$.addOption(private$..height3)
self$.addOption(private$..width2)
self$.addOption(private$..height2)
}),
active = list(
vars = function() private$..vars$value,
type = function() private$..type$value,
scale = function() private$..scale$value,
cor = function() private$..cor$value,
plot = function() private$..plot$value,
plot1 = function() private$..plot1$value,
plot2 = function() private$..plot2$value,
plot3 = function() private$..plot3$value,
width = function() private$..width$value,
height = function() private$..height$value,
width1 = function() private$..width1$value,
height1 = function() private$..height1$value,
width3 = function() private$..width3$value,
height3 = function() private$..height3$value,
width2 = function() private$..width2$value,
height2 = function() private$..height2$value),
private = list(
..vars = NA,
..type = NA,
..scale = NA,
..cor = NA,
..plot = NA,
..plot1 = NA,
..plot2 = NA,
..plot3 = NA,
..width = NA,
..height = NA,
..width1 = NA,
..height1 = NA,
..width3 = NA,
..height3 = NA,
..width2 = NA,
..height2 = NA)
)
rankResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"rankResults",
inherit = jmvcore::Group,
active = list(
instructions = function() private$.items[["instructions"]],
matrix = function() private$.items[["matrix"]],
plot = function() private$.items[["plot"]],
plot2 = function() private$.items[["plot2"]],
plot1 = function() private$.items[["plot1"]],
plot3 = function() private$.items[["plot3"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Ordinal Correlation",
refs="seolmatrix")
self$add(jmvcore::Html$new(
options=options,
name="instructions",
title="Instructions",
visible=TRUE))
self$add(jmvcore::Table$new(
options=options,
name="matrix",
title="`Correlation matrix - ${type}`",
visible="(matrix)",
clearWith=list(
"vars",
"type"),
refs="psych",
columns=list(
list(
`name`="name",
`title`="",
`type`="text",
`content`="($key)"))))
self$add(jmvcore::Image$new(
options=options,
name="plot",
title="Gaussian Graphical Model",
renderFun=".plot",
visible="(plot)",
refs="qgraph",
clearWith=list(
"vars",
"type",
"width",
"height")))
self$add(jmvcore::Image$new(
options=options,
name="plot2",
title="Centrality plot ",
renderFun=".plot2",
visible="(plot2)",
refs="qgraph",
clearWith=list(
"vars",
"type",
"scale",
"width2",
"height2")))
self$add(jmvcore::Image$new(
options=options,
name="plot1",
title="Partial plot",
renderFun=".plot1",
visible="(plot1)",
refs="qgraph",
clearWith=list(
"vars",
"type",
"width1",
"height1")))
self$add(jmvcore::Image$new(
options=options,
name="plot3",
title="Matrix plot",
renderFun=".plot3",
visible="(plot3)",
refs="corrgram",
clearWith=list(
"vars",
"type",
"width3",
"height3")))}))
rankBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"rankBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "seolmatrix",
name = "rank",
version = c(1,0,0),
options = options,
results = rankResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Ordinal Correlation
#'
#'
#' @param data The data as a data frame.
#' @param vars .
#' @param type .
#' @param scale .
#' @param cor .
#' @param plot .
#' @param plot1 .
#' @param plot2 .
#' @param plot3 .
#' @param width .
#' @param height .
#' @param width1 .
#' @param height1 .
#' @param width3 .
#' @param height3 .
#' @param width2 .
#' @param height2 .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$instructions} \tab \tab \tab \tab \tab a html \cr
#' \code{results$matrix} \tab \tab \tab \tab \tab a table \cr
#' \code{results$plot} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plot2} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plot1} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plot3} \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$matrix$asDF}
#'
#' \code{as.data.frame(results$matrix)}
#'
#' @export
rank <- function(
data,
vars,
type = "spearman",
scale = "raw",
cor = TRUE,
plot = FALSE,
plot1 = FALSE,
plot2 = FALSE,
plot3 = FALSE,
width = 500,
height = 500,
width1 = 500,
height1 = 500,
width3 = 500,
height3 = 500,
width2 = 500,
height2 = 500) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("rank 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 <- rankOptions$new(
vars = vars,
type = type,
scale = scale,
cor = cor,
plot = plot,
plot1 = plot1,
plot2 = plot2,
plot3 = plot3,
width = width,
height = height,
width1 = width1,
height1 = height1,
width3 = width3,
height3 = height3,
width2 = width2,
height2 = height2)
analysis <- rankClass$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.