rmOrphans | R Documentation |
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.
rmOrphans(
ind,
minN = 1,
reassign = FALSE,
side = "both",
silent = FALSE,
debug = FALSE,
callFrom = NULL
)
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 |
reassign |
(logical) if |
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 |
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.
This function returns an integer vector of adjusted indexes
table
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) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.