order_at_run_time: Order at run time

View source: R/order-at-run-time.R

order_at_run_timeR Documentation

Order at run time

Description

This helper function constructs a timeline where the order of test elements (or blocks of test elements) is determined at run time.

Usage

order_at_run_time(
  label,
  get_order,
  logic,
  save_order = function(order, state, ...) save_result(state, label, order)
)

Arguments

label

(Character scalar) A label for storing the generated order of test elements.

get_order

Function that should accept the arguments state and .... It will be called at run time, being passed the participant's state object. It should return a permutation of the integers 1 to N, where N is the length of the logic argument.

logic

List where each top-level element corresponds to a randomisation unit. These randomisation units may be either single test elements, lists of test elements, or timelines.

save_order

A function called at run time to save the result of get_order. It should accept three arguments: order, state, and .... order corresponds to the output of get_order, whereas state corresponds to the participant's state object. The default setting saves the generated order in psychTestR's default results repository, under the label label.

Value

A list of test elements, or equivalently a timeline, which can be combined with other test elements or timelines. These test elements will be presented in the order defined by the get_order function, with this function being called afresh for each new participant.

Note

This function can be nested arbitrarily many times.

See Also

randomise_at_run_time for the common application of randomising the order of test elements anew for each participant.


pmcharrison/psychTestR documentation built on Nov. 10, 2024, 9:03 p.m.