event_factor: Create a categorical event sequence from a factor.

View source: R/event-classes.R

event_factorR Documentation

Create a categorical event sequence from a factor.

Description

This is a user-facing wrapper around the internal event() constructor, specifically for creating categorical event sequences from factors or characters.

Usage

event_factor(fac, name, onsets, blockids = 1, durations = 0, subset = NULL)

Arguments

fac

A factor or something coercible to a factor.

name

Name of the event variable.

onsets

Numeric vector of event onsets (seconds).

blockids

Numeric vector of block IDs.

durations

Numeric vector of event durations (seconds), or a scalar.

subset

Optional logical vector indicating which events to keep. If provided, the vector must match onsets in length and contain no NA values.

Column names are sanitized using .sanitizeName() if provided. If column names are missing or not unique, deterministic feature suffixes (f01, f02, ...) are generated instead. The resulting names are returned by levels() for the event object.

Value

An S3 object of class event and event_seq.

See Also

event_model, event_variable, event_matrix, event_basis

Examples

efac <- event_factor(factor(c("a", "b", "c", "a", "b", "c")), "abc", 
        onsets = seq(1, 100, length.out = 6))
print(efac)
levels(efac)


bbuchsbaum/fmrireg documentation built on June 10, 2025, 8:18 p.m.