rmOrphans: Remove or Reassign Orphan Indexes

View source: R/rmOrphans.R

rmOrphansR Documentation

Remove or Reassign Orphan Indexes

Description

This function allows detecting terminal orphans of a vector of (cluster-) indexes and removing (ie marking as NA) or re-assigning them to the neighbour class towrds the center.

Usage

rmOrphans(
  ind,
  minN = 1,
  reassign = FALSE,
  side = "both",
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

ind

(integer) main input of (cluster-) indexes

minN

(numeric, length=1) the min frequency to consider as orphans, if less than 1 it will be interpreted as ratio compared to length of index

reassign

(logical) if TRUE orphan indexes will be replaced by neighbour class indexes (towrds the center)

side

(character) may be 'both', 'b', 'upper', 'u', 'lower' or 'l' to decide if lower and/or upper end indexes should be treated.

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allows easier tracking of messages produced

Details

All input of ind is supposed to be interger values as (cluster-) indexes. This function will look if the lowest and/or highest (cluster-) indexes appear at very low frequency so that they may be considered orphans. The argument minN assigns the threshold of when the frquency of terminal values may be considered as 'orphan', either as absolute threshold or if less than 1 as ratio (0.1 => 10

The argument side may be 'both', 'b', 'upper', 'u', 'lower' or 'l', to decide if lower and/or upper end indexes should be treated.

Value

This function returns an integer vector of adjusted indexes

See Also

table

Examples

 x=c(3:1,3:4,4:6,5:3); rmOrphans(x)
rmOrphans(x, minN=0.2) 
## reassign orphans to neighbour center class
cbind(x,  x=x, def=rmOrphans(x, reassign=TRUE), 
  minN=rmOrphans(x, minN=0.2, reassign=TRUE) )

wrMisc documentation built on Sept. 11, 2024, 6:10 p.m.