Learn R Programming

wrMisc (version 1.2.3)

cleanReplicates: Replace most distant values by NA

Description

This procedures aims to streighten (clean) the most extreme of noisy replicates by identifying the most distant points (among a set of replicates). The input 'x' (matrix or data.frame) is supposed to come from multiple different measures taken in replicates (eg weight of different individuals as rows taken as multiple replicate measures in subsequent columns). With the argument nOutl the user chooses the total number of most extreme values to replace by NA. how many of the most extreme replicates of the whole dataset will replaced by NA, ie with nOutl=1 only the single most extreme outlyer will be replaced by NA. Outlier points are determined as point(s) with highest distance to (row) center (median and mean choice via argument 'centrMeth'). Returns input data with "removed" points set to NA, or if retOffPos=TRUE the most extreme/outlier positions.

Usage

cleanReplicates(
  x,
  centrMeth = "median",
  nOutl = 2,
  retOffPos = FALSE,
  silent = FALSE,
  callFrom = NULL
)

Arguments

x

matrix (or data.frame)

centrMeth

(character) method to summarize (mean or median)

nOutl

(integer) determines how many points per line will be set to NA (with n=1 the worst row of replicates will be 'cleaned')

retOffPos

(logical) if TRUE, replace the most extreme outlyer only

silent

(logical) suppres messages

callFrom

(character) allow easier tracking of message(s) produced

Value

input data with "removed" points set as NA, or if retOffPos=TRUE the most extreme/outlier positions

Examples

Run this code
# NOT RUN {
mat3 <- matrix(c(19,20,30, 18,19,28, 16,14,35),ncol=3)
cleanReplicates(mat3,nOutl=1)
# }

Run the code above in your browser using DataLab