Skip to content

Example 1

Jonathon Love edited this page Nov 15, 2016 · 5 revisions

In this next example, example01.b.R has been modified to implement a basic independent samples t-test. It is as follows:

Example01Class <- R6::R6Class(
    "Example01Class",
    inherit = Example01Base,
    private = list(
        .init = function() {
            preformatted <- jmvcore::Preformatted$new(self$options, 'ttest')
            self$results$add(preformatted)
        },
        .run = function() {
            results <- self$results$get('ttest')
            results$content <- 'The fish was delish'
        })
)

jamovi analyses are run in two phases, an init phase, and a run phase. In the init phase, empty results objects (tables, etc.) are created. In the run phase, the analysis is performed, and the cells in results tables are filled in. The init phase is performed by the .init() function, and the run phase is performed by the .run() function.

In this example, in the .init() function, a Preformatted (for preformatted text) object called 'ttest' is created, and added to the analysis results.

In the .run() function, this performatted object is retrieved from the results, and the literal string The fish was delish is assigned to the content of this object.

You can run this analysis by selecting Example 01 from the jmvexamples menu, and see the expected result.

In the next example, we will make this analysis perform the t-test.

[Example 2](Example 2)

Tutorial

  • [Getting Started](Getting Started)
  • [Example 0](Example 0)
  • [Example 1](Example 1)
  • [Example 2](Example 2)
  • [Example 3](Example 3)
  • [Example 4](Example 4)
  • [Example 5](Example 5)

API

Clone this wiki locally