extract: Indexing to Extract Values of a Vegsoup* Object

Description Usage Arguments Details Note Author(s) See Also Examples

Description

Extract parts of an object. Currently, a replace method is not implemented!

Usage

1
2
3
4
## S4 method for signature 'Vegsoup'
x[i, j, ... , drop = TRUE]
## S4 method for signature 'VegsoupPartition'
partition(x, value)

Arguments

x

Vegsoup* object, for partition a VegsoupPartition object.

i, j, ...

Elements to extract or replace.

drop

Not used. The method will always return a valid Vegsoup* object!

value

integer. An integer defining a partition to be subsetted. Can also be a vector.

Details

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.

Note

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.

Author(s)

Roland Kaiser

See Also

subset, reorder

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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))

vegsoup documentation built on Feb. 24, 2021, 3 a.m.