Learn R Programming

diegr (version 0.2.0)

pick_data: Subsets EEG data by group, subject, sensor, time, experimental condition or epoch

Description

Filters an input dataset by optional constraints on group, subject, sensor, time, condition and epoch. Filters are combined with logical AND, and exact value matching (%in%) is used.

Usage

pick_data(
  data,
  group_rg = NULL,
  subject_rg = NULL,
  sensor_rg = NULL,
  condition_rg = NULL,
  epoch_rg = NULL,
  time_rg = NULL
)

Value

An object of the same class as data with rows filtered by the provided criteria; columns are unchanged. If all filters are NULL, the input is returned unmodified. If no rows match, the function ends with error message.

Arguments

data

A data frame, tibble or database table with input data. Required columns depend on the further parameters: setting subject_rg requires subject column etc.

group_rg

Optional vector of group identifiers to keep (character or numeric, matching data$group). If NULL (default), no filtering is applied based on group.

subject_rg

Optional vector of subject identifiers to keep (character or numeric, matching data$subject). If NULL (default), no filtering is applied based on subject.

sensor_rg

Optional vector of sensor identifiers to keep (character or numeric, matching data$sensor). If NULL (default), no filtering is applied based on sensor.

condition_rg

Optional vector of experimental condition identifiers to keep (character or numeric, matching data$condition). If NULL (default), no filtering is applied based on condition.

epoch_rg

Optional vector of epoch identifiers to keep (character or numeric, matching data$epoch). If NULL (default), no filtering is applied based on epoch.

time_rg

Optional vector of time points to keep (numeric, matching data$time). If NULL (default), no filtering is applied based on time.

Details

All filters are combined conjunctively (AND). Matching uses membership (%in%) with case-sensitive comparison for character columns. On database backends, very long *_rg vectors may not translate efficiently; consider pre-filtering or semi-joins.

See Also

compute_mean, baseline_correction, pick_region

Examples

Run this code
# Filtering epochs 1:5 and time points 1:10 for all subjects and sensor "E45"
data_subset <- pick_data(epochdata, sensor_rg = "E45",
 time_rg = 1:10, epoch_rg = 1:5)
head(data_subset)

# \donttest{
# Setting parameters outside the input data range (there is no subject 6 in epochdata)
# results in an error message
try(
pick_data(epochdata, subject_rg = 6,
 time_rg = 1:10, epoch_rg = 1:5)
 )
# }

Run the code above in your browser using DataLab