Extract by Index {vegsoup} | R Documentation |
Extract parts of an object. Currently, a replace method is not implemented!
## S4 method for signature 'Vegsoup' x[i, j, ... , drop = TRUE] ## S4 method for signature 'VegsoupPartition' partition(x, value)
x |
|
i, j, ... |
Elements to extract or replace. |
drop |
Not used. The method will always return a valid |
value |
|
If only one plot is requested for indexing (e.g. x[1,]
) the
summary
and show
methods additionally print a species list.
Any doubled numerical indices are silently ignored.
When objects of class VegsoupPartition
are subsetted it is likely that
the partitioning vector (partitioning(obj)
) has to be subsetted too.
If this is the case, the number of partitions k
(getK(obj)
) is
changed (lowered) accordingly.
Roland Kaiser
require(vegsoup) data(barmstein) x <- barmstein # index the species matrix and get new objects # select rows, the plots # first two plots x[ 1:2, ] # select columns (the species) including layer replicates # 10 random species x[ , sample(ncol(x), size = 10) ] # note, sample may result in an object that holds less then 'size' species # because of layer replication # remove species with equal or less than three occurences, # exact if there is no layer replication x[, colSums(x) >= 3] any(colSums(x[, colSums(x) >= 3]) < 3) # assigment using object slots rownames(x) sites(x) <- sites(x)[ sample(nrow(x)), ] rownames(x) # extract partitions x <- VegsoupPartition(x, k = 3) # extract partition 1 partition(x, 1) # drop partition 2 and 3 partition(x, -c(2,3)) # extract partition 2 and 3 partition(x, c(2,3)) # as above using logical index vector partition(x, c(FALSE, TRUE, TRUE))