dif.wave {erp.easy} | R Documentation |
Calculate a difference waveform from two data sets
Description
dif.wave
calculates a difference waveform from two data frames in the format
returned from load.data
Usage
dif.wave(x, z, name = NULL, keep = NULL)
Arguments
x |
A data frame in the format returned from |
z |
A data frame in the format returned from |
name |
Specify the Stimulus column name of the difference data frame. Must provide the new name in quotations. |
keep |
Include one of the data frames used in subtraction in the returned difference data frame.
By default |
Details
The data frames must either:
have been imported using
load.data
- OR -for subset data, the "Stimulus" column must be "refactored." See the example below for one way to "reset" the factors in the "Stimulus" column. Note this procedure is only necessary for subset data, and not data frames that were independently imported.
Value
One of two possible data frames, depending on the value of keep
:
-
keep
= "y": the difference (i.e., x - z) data frame and the minuend data frame (i.e., x) -
keep
= "n": just the difference data frame
Author(s)
Travis Moore
Examples
# Calculate a difference wave
Negative = ERPdata[1:6765, ]
Neutral = ERPdata[6766:13530, ]
refactor.neg <- factor(Negative$Stimulus)
refactor.neut <- factor(Neutral$Stimulus)
Negative$Stimulus <- refactor.neg
Neutral$Stimulus <- refactor.neut
difference <- dif.wave(Negative, Neutral, name = "Neg - Neut", keep = Neutral)
head(difference) # view the new Stimulus column name
grandaverage(difference, "V78") # plot the grand average difference wave