R/texta.h.R

Defines functions TextA

# This file is automatically generated, you probably don't want to edit this

TextAOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "TextAOptions",
    inherit = jmvcore::Options,
    public = list(
        initialize = function(
            dep = NULL,
            indep = NULL,
            wcpa = 1,
            hmwtd = 5, ...) {

            super$initialize(
                package="TextAnalytics",
                name="TextA",
                requiresData=TRUE,
                ...)

            private$..dep <- jmvcore::OptionVariables$new(
                "dep",
                dep)
            private$..indep <- jmvcore::OptionVariable$new(
                "indep",
                indep)
            private$..wcpa <- jmvcore::OptionNumber$new(
                "wcpa",
                wcpa,
                min=1,
                max=3,
                default=1)
            private$..hmwtd <- jmvcore::OptionNumber$new(
                "hmwtd",
                hmwtd,
                min=5,
                max=20,
                default=5)

            self$.addOption(private$..dep)
            self$.addOption(private$..indep)
            self$.addOption(private$..wcpa)
            self$.addOption(private$..hmwtd)
        }),
    active = list(
        dep = function() private$..dep$value,
        indep = function() private$..indep$value,
        wcpa = function() private$..wcpa$value,
        hmwtd = function() private$..hmwtd$value),
    private = list(
        ..dep = NA,
        ..indep = NA,
        ..wcpa = NA,
        ..hmwtd = NA)
)

TextAResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "TextAResults",
    inherit = jmvcore::Group,
    active = list(
        text = function() private$.items[["text"]]),
    private = list(),
    public=list(
        initialize=function(options) {
            super$initialize(
                options=options,
                name="",
                title="Term Frequency Analysis")
            self$add(jmvcore::Preformatted$new(
                options=options,
                name="text",
                title="Term Frequency Analysis"))}))

TextABase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
    "TextABase",
    inherit = jmvcore::Analysis,
    public = list(
        initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
            super$initialize(
                package = "TextAnalytics",
                name = "TextA",
                version = c(1,0,0),
                options = options,
                results = TextAResults$new(options=options),
                data = data,
                datasetId = datasetId,
                analysisId = analysisId,
                revision = revision,
                pause = NULL,
                completeWhenFilled = FALSE,
                requiresMissings = FALSE)
        }))

#' Term Frequency Analysis
#'
#' 
#' @param data .
#' @param dep .
#' @param indep .
#' @param wcpa .
#' @param hmwtd .
#' @return A results object containing:
#' \tabular{llllll}{
#'   \code{results$text} \tab \tab \tab \tab \tab a preformatted \cr
#' }
#'
#' @export
TextA <- function(
    data,
    dep,
    indep,
    wcpa = 1,
    hmwtd = 5) {

    if ( ! requireNamespace("jmvcore", quietly=TRUE))
        stop("TextA requires jmvcore to be installed (restart may be required)")

    if ( ! missing(dep)) dep <- jmvcore::resolveQuo(jmvcore::enquo(dep))
    if ( ! missing(indep)) indep <- jmvcore::resolveQuo(jmvcore::enquo(indep))
    if (missing(data))
        data <- jmvcore::marshalData(
            parent.frame(),
            `if`( ! missing(dep), dep, NULL),
            `if`( ! missing(indep), indep, NULL))


    options <- TextAOptions$new(
        dep = dep,
        indep = indep,
        wcpa = wcpa,
        hmwtd = hmwtd)

    analysis <- TextAClass$new(
        options = options,
        data = data)

    analysis$run()

    analysis$results
}
ps0101/Jamovi-TM documentation built on Dec. 22, 2021, 9:55 a.m.