is_categorical | R Documentation |
Determines if a variable represents categorical (factor-based) rather than continuous data.
For event terms, categorical variables are those that have discrete factor levels (like
trial types or conditions) rather than numeric values. For example, stimulus types
("face", "house") would be categorical, while reaction times would be continuous.
This function is complementary to is_continuous()
.
is_categorical(x)
x |
The object to check (typically an event_term, event_seq, or event_matrix) |
Logical; TRUE if the variable is categorical (factor-based), FALSE if continuous
is_continuous()
, event_term()
Other variable_type:
is_continuous()
# Create event terms with different types
# Categorical event (factor)
event_data <- data.frame(
condition = factor(c("face", "house", "face", "house")),
onsets = c(1, 10, 20, 30),
run = c(1, 1, 1, 1)
)
cat_term <- event_term(
list(condition = event_data$condition),
onsets = event_data$onsets,
blockids = event_data$run
)
is_categorical(cat_term) # Returns: TRUE
# Continuous event (numeric)
event_data$intensity <- c(0.8, 1.2, 0.9, 1.1) # stimulus intensity
cont_term <- event_term(
list(intensity = event_data$intensity),
onsets = event_data$onsets,
blockids = event_data$run
)
is_categorical(cont_term) # Returns: FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.