set_variables: Modify a timeline to set possible values for variables

Description Usage Arguments Details Value See Also Examples

View source: R/timeline_modify.R

Description

Modify a timeline to set possible values for variables

Usage

1
set_variables(timeline, ...)

Arguments

timeline

The timeline object

...

A set of name/value pairs defining the timeline variables

Details

When creating an experiment, a common pattern is to create a series of trials that are identical in every respect except for one thing that varies across the trial (e.g., a collection of trial_html_button_response() trials that are the same except for the text that is displayed). A natural way to handle this in the jsPsych framework is to create the trial in the usual fashion, except that instead of specifying the value that needs to be included in the trial (e.g., the text itself) the code includes a reference to a timeline variable. Inserting the reference to the variable is the job of the insert_variable() function; attaching that variable to the timeline and specifying its possible values is the job of set_variables. This is most easily explained by using an example, as shown below.

Value

The modified timeline object

See Also

build_timeline, insert_variable

Examples

1
2
3
4
5
6
7
# create a template from which a series of trials can be built
template <- trial_html_button_response(stimulus = insert_variable("animal"))

# create a timeline with three trials, all using the same template
# but with a different value for the "animal" variable
timeline <- build_timeline(template) %>%
  set_variables(animal = c("cat", "dog", "pig"))

djnavarro/jaysire documentation built on April 12, 2021, 4:25 a.m.