Variable Option

The Variable option allows the user to select a single variable (column) from the dataset.

Description

In the jamovi UI, a Variable option is represented as a Target Drop Box. Users can drag a single variable from the variable supplier into this slot. It is commonly used for dependent variables in simple tests or grouping variables.

YAML Properties

PropertyTypeDescription
namestringThe unique name of the option.
typestringMust be Variable.
titlestringThe label displayed in the UI.
suggestedarrayA list of suggested variable types (e.g., [continuous]).
permittedarrayA list of permitted variable types (e.g., [continuous, ordinal, nominal]).
rejectInfbooleanIf true, the analysis will error if the variable contains infinite values. Defaults to true.
rejectMissingbooleanIf true, the analysis will error if the variable contains missing values. Defaults to false.

R Implementation

In R, a Variable option is represented as a character string (a character vector of length 1) containing the name of the variable. If no variable is assigned, it is NULL.

Examples

1. Define in YAML

- name: dep
  type: Variable
  title: Dependent Variable
  suggested:
    - continuous
  permitted:
    - continuous
    - ordinal

2. Implementation in R

Access the variable name using self$options$name:

depName <- self$options$dep

if ( ! is.null(depName)) {
    # Get the actual data column
    column <- self$data[[depName]]
}