# This file is automatically generated, you probably don't want to edit this
networkOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"networkOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
labels = NULL,
vars = NULL,
cen = TRUE,
plot = FALSE,
width = 500,
height = 500, ...) {
super$initialize(
package="seolmatrix",
name="network",
requiresData=TRUE,
...)
private$..labels <- jmvcore::OptionVariable$new(
"labels",
labels,
suggested=list(
"nominal"),
permitted=list(
"id",
"factor"))
private$..vars <- jmvcore::OptionVariables$new(
"vars",
vars)
private$..cen <- jmvcore::OptionBool$new(
"cen",
cen,
default=TRUE)
private$..plot <- jmvcore::OptionBool$new(
"plot",
plot,
default=FALSE)
private$..width <- jmvcore::OptionInteger$new(
"width",
width,
default=500)
private$..height <- jmvcore::OptionInteger$new(
"height",
height,
default=500)
self$.addOption(private$..labels)
self$.addOption(private$..vars)
self$.addOption(private$..cen)
self$.addOption(private$..plot)
self$.addOption(private$..width)
self$.addOption(private$..height)
}),
active = list(
labels = function() private$..labels$value,
vars = function() private$..vars$value,
cen = function() private$..cen$value,
plot = function() private$..plot$value,
width = function() private$..width$value,
height = function() private$..height$value),
private = list(
..labels = NA,
..vars = NA,
..cen = NA,
..plot = NA,
..width = NA,
..height = NA)
)
networkResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"networkResults",
inherit = jmvcore::Group,
active = list(
instructions = function() private$.items[["instructions"]],
text = function() private$.items[["text"]],
cen = function() private$.items[["cen"]],
plot = function() private$.items[["plot"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Directed Graph Centrality",
refs="seolmatrix")
self$add(jmvcore::Html$new(
options=options,
name="instructions",
title="Instructions",
visible=TRUE))
self$add(jmvcore::Preformatted$new(
options=options,
name="text",
title=""))
self$add(jmvcore::Table$new(
options=options,
name="cen",
title="Centrality",
visible="(cen)",
rows="(vars)",
clearWith=list(
"vars",
"labels"),
refs="qgraph",
columns=list(
list(
`name`="name",
`title`="",
`type`="text",
`content`="($key)"),
list(
`name`="bet",
`title`="Betweenness"),
list(
`name`="clo",
`title`="Closeness"),
list(
`name`="ind",
`title`="InDegree"),
list(
`name`="out",
`title`="OutDegree"),
list(
`name`="outex",
`title`="OutExpectedInfluence"),
list(
`name`="inex",
`title`="InExpectedInfluence"))))
self$add(jmvcore::Image$new(
options=options,
name="plot",
title="Directed Graph Centrality",
requiresData=TRUE,
visible="(plot)",
renderFun=".plot",
refs="qgraph",
clearWith=list(
"vars",
"labels",
"width",
"height")))}))
networkBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"networkBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "seolmatrix",
name = "network",
version = c(1,0,0),
options = options,
results = networkResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Directed Graph Centrality
#'
#'
#' @param data The data as a data frame.
#' @param labels .
#' @param vars .
#' @param cen .
#' @param plot .
#' @param width .
#' @param height .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$instructions} \tab \tab \tab \tab \tab a html \cr
#' \code{results$text} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$cen} \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$cen$asDF}
#'
#' \code{as.data.frame(results$cen)}
#'
#' @export
network <- function(
data,
labels,
vars,
cen = TRUE,
plot = FALSE,
width = 500,
height = 500) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("network requires jmvcore to be installed (restart may be required)")
if ( ! missing(labels)) labels <- jmvcore::resolveQuo(jmvcore::enquo(labels))
if ( ! missing(vars)) vars <- jmvcore::resolveQuo(jmvcore::enquo(vars))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(labels), labels, NULL),
`if`( ! missing(vars), vars, NULL))
options <- networkOptions$new(
labels = labels,
vars = vars,
cen = cen,
plot = plot,
width = width,
height = height)
analysis <- networkClass$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.