filtRT: Filter reaction times values with thresholds values and/or...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/filtRT.R

Description

A function to remove outliers of a given data frame. Based on the outliers function of the present package. filtRT applies the outliers function according to each subject and/or condition. Data can be excluded based on a minimal/maximal values (thresholds) and/or based on a given standard deviation value from the mean. Outliers are excluded either from all values or regarding each subject and condition. Return a data frame of filtered data as well as the percentage of data filtered.

Usage

1
filtRT(dt, RT = "RT", vars = NULL, fpass = NULL, sdv = NULL)

Arguments

RT

A string indicating the column names the data to filter. Defaults to 'RT'.

vars

A vector of name to indicate the column names of variables to use to filter the data by condition, usually subjects and at least one independent variable.

fpass

A vector length two with the minimal and maximal accepted value to use for a first filtering of the reaction times. To filter only the lowest or highest values, indicate NA as value. For instance c(100, NA) will only remove RT < 100ms. Defaults to NULL.

sdv

A number indicating how many standard deviations should be used to filter the data. Defaults to NULL.

data

A data frame in the long format (one row per record).

Value

Return a list with a data frame of filtered data and a data frame of number of data excluded and its relative percentage per condition.

Author(s)

Guillaume T. Vallet gtvallet@gmail.com, University of de Montreal (Canada);

Benoit A. Riou riouba@gmail.com, Lyon2 University (France)

See Also

outliers

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Generate fake data with a subject number in the first colum, a fake experimental condition
 in the second column and fake reaction times in the third column
df = rbind(data.frame(Subj=1, Cond="Test", RT=rnorm(25, mean=550, sd=48)),
           data.frame(Subj=1, Cond="Control", RT=rnorm(25, mean=680, sd=62)),
           data.frame(Subj=2, Cond="Test", RT=rnorm(25, mean=585, sd=54)),
           data.frame(Subj=2, Cond="Control", RT=rnorm(25, mean=720, sd=59)))

# Adding extreme values
df[75,3]  = df[5,3]+300
df[25,3] = df[5,3]+500
df[79,3] = df[19,3]-350
df[33,3] = df[33,3]+420
df[40,3] = df[40,3]-520
df[27,3] = df[27,3]-350
df[9,3]  = 50
df[86,3] = 4250
df[65,3] = 99
df[3,3]  = 1999

Filter with low and high thresolds and with 3 standard deviations
  by subject and condition
filtRT(df, RT='RT', vars=c('Subj', 'Cond'), fpass=c(100,1000), sdv=3)

# Filter with only a low thresold with 2 standard deviations by subjects
filtRT(df, RT='RT', vars='Subj', fpass=c(100, NA), sdv=2)
 

Cogitos/statxp documentation built on March 22, 2021, 6:38 a.m.