Created
December 21, 2011 08:05
-
-
Save thomasjensen/1505156 to your computer and use it in GitHub Desktop.
vectorized function for getting outliers in rows of a matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data <- cbind(rnorm(100),rnorm(100),rnorm(100)) | |
outlierMat <- function(mat) { | |
m <- rowMeans(mat) | |
devs <- abs(mat - m) | |
val <- apply(mat, 1, max) | |
pos <- which(mat == val, arr.ind = TRUE) | |
out <- cbind(pos,val) | |
return(out) | |
} | |
out <- outlierMat(data) | |
out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment