layers: Get or Modify Layers

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

Description

Modify an object's layer structure by suppling a layer combination vector as a character argument collapse. A layer that is intended to be collapsed with one or more layers is simply given the same value of collapse. Different aggregation modes are provided.

Usage

1
2
3
4
5
6
## S4 method for signature 'Vegsoup'
layers(obj, collapse, aggregate = c("layer", "mean", "min", "max", "sum"),
	   dec = 0, verbose = FALSE)

## S4 replacement method for signature 'Vegsoup'
layers(obj) <- value

Arguments

obj

Vegsoup* object.

collapse

character. Vector defining a combination of layers. The order of strings matters!

aggregate

character. Layer aggregation mode, defaults to aggregate = "layer".

dec

integer. Number of decimals for calculation, defaults to 0. If this is not appropriate for coverscale(obj), the value is increased as necessary.

value

character. Permutation of layers(obj) to reorder layers.

verbose

logical. Prints messages.

Details

A data set composed of more than one layer might be represented as a multidimensional dimensional array, where there are as many dimensions as there are layers. Unfortunately, many multivariate methods require a matrix-valued response variable (two-dimensional matrix).

The design of package vegsoup with regard to layer replication is to encode species and layer in a collapsed string which is used then as column names in the species matrix. This so circumvents the creation of multi dimensional arrays. layers build blocks in the species matrix. The order is determined by layers(obj).

For practical reasons, the vegsoup package collapses the species and layer dimension into a single string by using the special mark-up character '@'. This concatenation takes place if a species matrix is requested from the object, column names are built ad-hoc based on the Species object stored in slot 'species'. The order in which the collapsed dimension (layer replicates) appears in the column names of the resulting matrix is controlled by the order of layers(obj). Permuting this order also reorders the blocks of layers.

In stage of aggregating several data sources it might be necessary to homogenize the various layers present in the object. For this task some basic aggregation modes are provided. Aggregation mode "layer" combines layers assuming their independence (Fischer 2015). For example, a species occurring in two layers with a cover of 50 % will result in an overall cover of 75 %. Mode "sum" will sum up cover values of all layers (see tv.veg). If collapse is missing, or of length 1 all layers are collapsed and labeled according to the value of collapse, or 0l if collapse is missing. If collapse is a character vector it has to match length(layers(obj)) (see ‘Examples’).

Value

An object depending on the input class.

Note

The returned object is reordered by plot, abbr and layer!

If there are any NAs in collapse all species that occur only on these layers will be dropped from the data set and a warning is issued. This can be useful e.g. if you want to drop cryptogams (bryophytes and/or lichens) from a dataset that has no complete coverage for these taxa and would otherwise influence the analysis (see ‘Examples’).

Author(s)

Roland Kaiser, inspired by code from Florian Jansen for function tv.veg in package vegdata.

References

Mucina, L., Schaminee, J., and Rodwell, J. (2000). Common data standards for recording relevées in field survey for vegetation classification. Journal of Vegetation Science, 11: 769-772.

Fischer, H. S. (2015). On the combination of species cover values from different vegetation layer. Applied Vegetation Science, 18: 169-170.

See Also

layer, abbr.layer, Vegsoup and class Vegsoup

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require(vegsoup)

data(windsfeld)
x <- windsfeld

#   print layers
layers(x)

# change order of layers
layers(x) <- c("ml", "hl", "sl", "tl2", "tl1")
layers(x)

# assign wl to sl, tl1 and tl2
# see ?windsfeld for details
x1 <- layers(x, aggregate = "layer",
				collapse = c("hl", "ml", "wl", "wl", "wl"),
				verbose = TRUE)
layers(x1)
# check dimension of data set
# dim(obj)[1] gives number of sites (unique sample plots)
# dim(obj)[2] gives number of species
dim(x1)

# collpase all layers
x2 <- layers(x, aggregate = "layer", collapse = c("ol"),
				verbose = TRUE)
layers(x2); dim(x2)

# ... another way adopting default labeling
x3 <- layers(x, aggregate = "layer",
				verbose = TRUE)
layers(x3); dim(x3)

# drop layer sl aswell as tl1 and tl2
x4 <- layers(x, aggregate = "layer",
				collapse = c("ml", "hl", NA, NA, NA),
				verbose = TRUE)
layers(x4)
dim(x4)

# this way we loose most of the plots
x5 <- layers(x, aggregate = "layer",
				collapse = c(NA, NA, NA, "wl", "wl"),
				verbose = TRUE)
layers(x5)
dim(x5)

# subsetting will also extract layers appropiately
layers(x[, grep("@tl", colnames(x))])

# the species<– replacement method provides another means of subsetting
x6 <- x
species(x6) <- species(x)[species(x)$layer == layers(x)[1], ]
layers(x6)
# plots without cryptogams
rownames(x)[-match(rownames(x6), rownames(x))]

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