fence: Fence Values Based on Mean and Standard Deviation

View source: R/fence.R

fenceR Documentation

Fence Values Based on Mean and Standard Deviation

Description

Identifies values of x that are a certain number of standard deviations from the mean and replaces them with that boundary value (e.g., values more than 3 standard deviations from the mean are replaced with the mean +/= 3 standard deviations).

Usage

fence(x, sds = 3, print = TRUE, na.rm = FALSE)

Arguments

x

vector of values to which the fencing procedure should be applied.

sds

number of standard deviations away from the mean at which values should be replaced.

print

a logical value indicating whether to display the number and percentage of replaced values.

na.rm

a logical value indicating whether NA values should be ignored when computing the mean and standard deviation.

Details

This function is provided because this is a standard data processing procedure in the psycholinguistic literature and not as an endorsement or rejection of this or any other procedure.

Value

vector in which values more than the specified number of standard deviations from the mean have been replaced with the boundary value.

See Also

flag.by.sds to identify such observations without replacing them.

trim to treat such observations as missing data rather than replacing them with a new value.

fence.by.group to fence values a certain number of standard deviations away from a group mean (e.g., the mean within a condition or the mean for a research participant) rather than the overall mean.

Examples

my.data <- data.frame(RT=rnorm(300, mean=789, sd=150))
my.data$FencedRT <- fence(my.data$RT, sds=2.5)

sfraundorf/psycholing documentation built on April 23, 2022, 2:50 a.m.