In psychTestR, modules are ways of wrapping sequences of test elements into coherent logical units. Putting a sequence of test elements into a module has three main consequences:

  1. Readability: It makes it clear to the reader that this sequence of test elements forms a single logical unit.

  2. Results organisation: Any results generated in this module will be assigned to a special section in the psychTestR results object, labelled with the name of the module.

  3. Protected local environment: The module will receive a fresh local environment where it can create its own local variables (see set_local). This local environment is protected from other modules, which is useful to avoid unexpected side effects when multiple modules are chained together.

module(label, ...)



Label for the module; must be limited to alphanumeric characters and underscores.


The psychTestR test elements that will constitute the module.


In many cases modules will typically be used in one flat layer. However, it is perfectly possible to nest modules to arbitrary depths; at any point in time, only the local variables from the lowest-level module will be visible. The results object will use a composite label derived by concatenating the names of the modules, separated by periods, for example parent.child.grandchild.

See also

This function wraps the low-level functions begin_module and end_module.