Learn R Programming

erpR (version 0.2.0)

create.roi: create electrode region of interests

Description

An utility function to create a factor that collapses other factor levels (typically electrode names) in a new variable vector with the new ROI (region of interest) variable. It can be used only with data.frame in long format.

Usage

create.roi(datall, electrode="electrode", groups=NULL, roi.levels=NULL )

Arguments

datall
a data frame containing ERP data in long format.
electrode
name of the column in datall containing electrode names.
groups
a list containing (in separate vectors) electrode names to create the ROI. E.g. list(c("Fp1", "Fp2"), c("P3", "P4")).
roi.levels
a vector with the names of the newly created factor variable. E.g. c("Frontopolar", "Parietal").

Value

The function returns a vector with the new coded ROI variable.

Details

All levels of the variable electrode that are not specified in groups will be coded as NA in the returned vector.

Examples

Run this code

data(ERPsets)

datall=erp.mean(base = "Exp1_word_subj", numbers = 1:20,
 win.ini = 400, win.end = 600, startmsec= -200, endmsec=1500, erplist=ERPsets)

datall$caudality=create.roi(datall, "electrode", 
groups=list(c("Fp1", "Fp2"), c("P3", "P4")), 
roi.levels=c("Frontopolar", "Parietal"))

table(datall$caudality, datall$electrode)
	

Run the code above in your browser using DataLab