display_if: Modify a timeline to execute if a condition is met

Description Usage Arguments Details Value See Also

View source: R/timeline_modify.R

Description

Modify a timeline to execute if a condition is met

Usage

1
display_if(timeline, conditional_function)

Arguments

timeline

A timeline object

conditional_function

A javascript function that returns true if the timeline should execute and false otherwise

Details

The display_if() function is used to modify an existing timeline object, and provides the ability for conditional branching within an experiment. To use it, the user must supply the conditional_function, a javascript function that executes at runtime and should evaluate to true or false. If the conditional function returns true, then the timeline object will execute; if the conditional function returns false then jsPsych will not run this timeline.

At present jaysire provides only limited tools for writing the conditional function. The fn_data_condition() function allows a simple approach that allows the conditional function to query the jsPsych data store, but only in a limited way. Future versions will (hopefully) provide a richer tool set for this. However, for users who are comfortable with writing javascript functions directly the insert_javascript() function may be useful.

Value

The modified timeline object

See Also

display_while, build_timeline, fn_data_condition, insert_javascript


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