collapse abbreviations {vegsoup} | R Documentation |
Vegsoup*
Objects Deparse the layer replications (pseudo-species) used as colnames
in the
species matrix of Vegsoup*
objects into it's components.
## S4 method for signature 'Vegsoup' splitAbbr(obj) decode(x, obj)
obj |
|
x |
|
The splitAbbr
method decomposes the colnames
of the species
matrix into three components. The first giving the taxon abbreviation only
(abbr
), the second the layer code (layer
) and the last
component corresponds to the full taxon name (taxon
) as queried
from taxonomy(obj)
.
The compound taxon key (abbr.layer
) can be accessed from the
rownames
of the resulting object. This is advantageous as it provides
an easy means of subsetting with colnames(obj)
.
decode
is equivalent to the above method, but works for base
classes (see ‘Examples’). However, an appropriate
Vegsoup
or Taxonomy
object
has to be supplied to query scientific taxon names.
Vegsoup
and Species
construct these
compound taxon abbreviations by pasting make.names(x)
and
layer
seperated with "@"
. To deparse the abbreviation and
layer string splitAbbr
should be used.
A "data.frame"
with as many rows and in the same order as there are
columns in the species matrix. Note, the method uses invisible
when
returning it's results.
Roland Kaiser
Vegsoup
Taxonomy
taxalist
taxon
require(vegsoup) data(barmstein) x <- barmstein # deparse compund taxon and layer replicates a <- splitAbbr(x) head(a) all.equal(rownames(a), colnames(x)) # get scientific taxa names for the columns of the species matrix # as.matrix returns a species matrix from an 'Vegsoup' object # we use mode = "R" for instantaneous matrix transposition m <- as.matrix(x, typeof = "character", mode = "R") head(a[rownames(m), ]) # for a unique list of taxa taxon(x) # similar result but a matrix head(taxalist(x, layered = TRUE)) # species matrix including taxon names and layers m <- cbind(a[rownames(m), ], m) # and this can be converted bach to class 'Species' ( stackSpecies(m) ) # indexing of 'Vegsoup' object by suppling indices of the the species matrix # elements according to 'as.matrix' method x[, rownames(a)[sample(1:ncol(x), 10)]] # decode rownames of matrix ... class(xx <- constancy(x)) decode(xx, x) rownames(xx) <- apply(sapply(decode(xx, x)[c("taxon", "layer")], paste), 1, paste, collapse = "@") head(xx) # ... data.frame and Taxonomy object class(xx <- splitAbbr(x)) decode(xx, taxonomy(x)) # character vector without layer encoded with '@' decode(taxalist(x)$abbr, x) # a named list decode(spread(VegsoupPartition(x, k = 2)), x)