View source: R/outlier.matrix.R
outlier.matrix | R Documentation |
Given a matrix of data this function returns a matrix of 0|1, of the same structure with 1 values indicating outliers. It is an expansion of the function id.outliers(), applied to columns of a matrix.
outlier.matrix(data, nsd = 5, meansd = FALSE)
data |
a matrix of numerical values, samples in row, features in columns |
nsd |
the unit distance in SD or IQR from the mean or median estimate, respectively outliers are identified at. Default value is 5. |
meansd |
set to TRUE if you would like to estimate outliers using a mean and SD method; set to FALSE if you would like to estimate medians and inter quartile ranges. The default is FALSE. |
a matrix of 0 (not a sample outlier) and 1 (outlier)
ex_data = sapply(1:25, function(x){ rnorm(250, 40, 5) }) ## define the data set rownames(ex_data) = paste0("ind", 1:nrow(ex_data)) colnames(ex_data) = paste0("var", 1:ncol(ex_data)) ## add in some technical error to two samples m = apply(ex_data, 2, function(x){ mean(x, na.rm = TRUE) }) ex_data[c(1,50), ] = ex_data[1, ] + (m*4) Omat = outlier.matrix(ex_data) ## how many outliers identified sum(Omat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.