Learn R Programming

spider (version 1.2-0)

rmSingletons: Detect and remove singletons

Description

A utility to detect and remove species represented only by singletons.

Usage

rmSingletons(sppVector, exclude = TRUE)

Arguments

sppVector
Vector of species names. (see sppVector).
exclude
Logical. Should singletons be removed? Default of TRUE.

Value

  • Returns a numeric vector giving the indices of the selected individuals.

Details

When exclude = TRUE (the default), singletons are excluded and the vector returns the index of all non-singletons in the dataset. When exclude = FALSE, the indices of the singletons are presented.

Examples

Run this code
data(anoteropsis)
anoDist <- dist.dna(anoteropsis)
anoSpp <- sapply(strsplit(dimnames(anoteropsis)[[1]], split="_"), 
    function(x) paste(x[1], x[2], sep="_"))

rmSingletons(anoSpp)
rmSingletons(anoSpp, exclude=FALSE)

data(dolomedes)
doloDist <- dist.dna(dolomedes)
doloSpp <- substr(dimnames(dolomedes)[[1]], 1, 5)

rmSingletons(doloSpp)
rmSingletons(doloSpp, exclude=FALSE)

Run the code above in your browser using DataLab