# This file is automatically generated, you probably don't want to edit this
ahpsurveyOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"ahpsurveyOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
vars = NULL,
atts = "cult, fam, house, jobs, trans",
ap = TRUE,
method = "geometric",
aj = FALSE,
method1 = "geometric",
method2 = "eigen",
method3 = "geometric",
sumcr = FALSE,
plot1 = FALSE,
width1 = 500,
height1 = 500, ...) {
super$initialize(
package="seolmatrix",
name="ahpsurvey",
requiresData=TRUE,
...)
private$..vars <- jmvcore::OptionVariables$new(
"vars",
vars,
suggested=list(
"nominal",
"ordinal"),
permitted=list(
"numeric"))
private$..atts <- jmvcore::OptionString$new(
"atts",
atts,
default="cult, fam, house, jobs, trans")
private$..ap <- jmvcore::OptionBool$new(
"ap",
ap,
default=TRUE)
private$..method <- jmvcore::OptionList$new(
"method",
method,
options=list(
"eigen",
"geometric",
"arithmetic",
"rootmean"),
default="geometric")
private$..aj <- jmvcore::OptionBool$new(
"aj",
aj,
default=FALSE)
private$..method1 <- jmvcore::OptionList$new(
"method1",
method1,
options=list(
"geometric",
"arithmetic",
"rootmean"),
default="geometric")
private$..method2 <- jmvcore::OptionList$new(
"method2",
method2,
options=list(
"eigen",
"geometric",
"arithmetic",
"rootmean"),
default="eigen")
private$..method3 <- jmvcore::OptionList$new(
"method3",
method3,
options=list(
"eigen",
"geometric",
"arithmetic",
"rootmean"),
default="geometric")
private$..sumcr <- jmvcore::OptionBool$new(
"sumcr",
sumcr,
default=FALSE)
private$..cr <- jmvcore::OptionOutput$new(
"cr")
private$..plot1 <- jmvcore::OptionBool$new(
"plot1",
plot1,
default=FALSE)
private$..width1 <- jmvcore::OptionInteger$new(
"width1",
width1,
default=500)
private$..height1 <- jmvcore::OptionInteger$new(
"height1",
height1,
default=500)
self$.addOption(private$..vars)
self$.addOption(private$..atts)
self$.addOption(private$..ap)
self$.addOption(private$..method)
self$.addOption(private$..aj)
self$.addOption(private$..method1)
self$.addOption(private$..method2)
self$.addOption(private$..method3)
self$.addOption(private$..sumcr)
self$.addOption(private$..cr)
self$.addOption(private$..plot1)
self$.addOption(private$..width1)
self$.addOption(private$..height1)
}),
active = list(
vars = function() private$..vars$value,
atts = function() private$..atts$value,
ap = function() private$..ap$value,
method = function() private$..method$value,
aj = function() private$..aj$value,
method1 = function() private$..method1$value,
method2 = function() private$..method2$value,
method3 = function() private$..method3$value,
sumcr = function() private$..sumcr$value,
cr = function() private$..cr$value,
plot1 = function() private$..plot1$value,
width1 = function() private$..width1$value,
height1 = function() private$..height1$value),
private = list(
..vars = NA,
..atts = NA,
..ap = NA,
..method = NA,
..aj = NA,
..method1 = NA,
..method2 = NA,
..method3 = NA,
..sumcr = NA,
..cr = NA,
..plot1 = NA,
..width1 = NA,
..height1 = NA)
)
ahpsurveyResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"ahpsurveyResults",
inherit = jmvcore::Group,
active = list(
instructions = function() private$.items[["instructions"]],
text = function() private$.items[["text"]],
ap = function() private$.items[["ap"]],
aj = function() private$.items[["aj"]],
sumcr = function() private$.items[["sumcr"]],
cr = function() private$.items[["cr"]],
plot1 = function() private$.items[["plot1"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="AHP for survey data",
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="ap",
title="`Preference weights - ${method}`",
visible="(ap)",
refs="ahpsurvey",
clearWith=list(
"vars",
"method"),
columns=list(
list(
`name`="name",
`title`="",
`type`="text",
`content`="($key)"),
list(
`name`="value",
`title`="Value"))))
self$add(jmvcore::Table$new(
options=options,
name="aj",
title="` Pairwise comparison matrix - ${method1}`",
refs="ahpsurvey",
visible="(aj)",
clearWith=list(
"vars",
"method1"),
columns=list(
list(
`name`="name",
`title`="",
`type`="text",
`content`="($key)"))))
self$add(jmvcore::Table$new(
options=options,
name="sumcr",
title="Summary of Consistency Ratio(CR<=0.1)",
rows=1,
visible="(sumcr)",
clearWith=list(
"vars"),
columns=list(
list(
`name`="name",
`title`="",
`type`="text",
`content`="Frequency"),
list(
`name`="NO",
`type`="integer"),
list(
`name`="YES",
`type`="integer"),
list(
`name`="Mean CR",
`type`="number"))))
self$add(jmvcore::Output$new(
options=options,
name="cr",
title="CR",
varTitle="CR",
measureType="continuous",
clearWith=list(
"vars")))
self$add(jmvcore::Image$new(
options=options,
name="plot1",
title="Compare different average methods",
visible="(plot1)",
renderFun=".plot1",
refs="ahpsurvey",
requiresData=TRUE,
clearWith=list(
"vars",
"method2",
"method3",
"width1",
"plot1")))}))
ahpsurveyBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"ahpsurveyBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "seolmatrix",
name = "ahpsurvey",
version = c(1,0,0),
options = options,
results = ahpsurveyResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'none')
}))
#' AHP for survey data
#'
#'
#' @param data The data as a data frame.
#' @param vars .
#' @param atts .
#' @param ap .
#' @param method .
#' @param aj .
#' @param method1 .
#' @param method2 .
#' @param method3 .
#' @param sumcr .
#' @param plot1 .
#' @param width1 .
#' @param height1 .
#' @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$ap} \tab \tab \tab \tab \tab a table \cr
#' \code{results$aj} \tab \tab \tab \tab \tab a table \cr
#' \code{results$sumcr} \tab \tab \tab \tab \tab a table \cr
#' \code{results$cr} \tab \tab \tab \tab \tab an output \cr
#' \code{results$plot1} \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$ap$asDF}
#'
#' \code{as.data.frame(results$ap)}
#'
#' @export
ahpsurvey <- function(
data,
vars,
atts = "cult, fam, house, jobs, trans",
ap = TRUE,
method = "geometric",
aj = FALSE,
method1 = "geometric",
method2 = "eigen",
method3 = "geometric",
sumcr = FALSE,
plot1 = FALSE,
width1 = 500,
height1 = 500) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("ahpsurvey 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))
options <- ahpsurveyOptions$new(
vars = vars,
atts = atts,
ap = ap,
method = method,
aj = aj,
method1 = method1,
method2 = method2,
method3 = method3,
sumcr = sumcr,
plot1 = plot1,
width1 = width1,
height1 = height1)
analysis <- ahpsurveyClass$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.