winsorize.matrix: Winsorize matrix

Description Usage Arguments Value Examples

View source: R/functions.R

Description

Sets the ncol(mat)*trim top outliers in each row to the next lowest value same for the lowest outliers

Usage

1
winsorize.matrix(mat, trim)

Arguments

mat

matrix

trim

fraction of outliers (on each side) that should be Winsorized, or (if the value is >= 1) the number of outliers to be trimmed on each side

Value

Winsorized matrix

Examples

1
2
3
4
5
6
set.seed(0)
mat <- matrix( c(rnorm(5*10,mean=0,sd=1), rnorm(5*10,mean=5,sd=1)), 10, 10)  # random matrix
mat[1,1] <- 1000  # make outlier
range(mat)  # look at range of values
win.mat <- winsorize.matrix(mat, 0.1)
range(win.mat)  # note outliers removed

scde documentation built on Nov. 8, 2020, 6:19 p.m.