taxon: Get or Subset Object by Scientific Taxon Name

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

Description

Print or retrieve a character vector of full scientific latin names of taxa as defined by taxonomy(x). Alternatively, subset an object based on taxon names, such that only the selected species, or only those plots where selected species occurs in, remain in the object.

Usage

1
2
3
4
5
## S4 method for signature 'Vegsoup'
taxon(x, taxon = NULL)

## S4 method for signature 'Vegsoup'
subset(x, subset, drop = TRUE, ...)

Arguments

x

Vegsoup* object.

taxon

character string of a full scientific latin name (see taxonomy).

subset

numeric index to taxonomy(x), vector of mode character, or a logical expression.

drop

logical, if TRUE only the selected species remain.

...

Arguments passed to grep.

Details

Function taxon retrieves scientific species names from an object.

If argument taxon is supplied only those taxa returned by a call to grep(taxon, taxon(x))] are printed.

Extending the functionality of the Extract methods for vegsoup objects, that allow for a definition of subsets based on abbreviations as returned by colnames, this set of methods provides other means of selecting species.

By using the the subset-method it becomes possible to select species based on their taxonomic classification or other traits that go along with species names.

If subset is of mode character the string is passed to function grep and seeked in column 'taxon' of taxonomy(x). Argument "subset" can be a vector of length 1 or more.

Value

A Vegsoup* object.

Author(s)

Roland Kaiser

See Also

Extract

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
data(barmstein)
x <- barmstein

head(taxon(x)) # short-hand for head(taxonomy(x)$taxon)

# display all taxa staring with letter C
taxon(x, "C")
 
# subset object using a species scientific name
# and use function taxon() for display
taxon(subset(x, "Carex")) # drop = TRUE is the default
taxon(subset(x, "Carex", drop = FALSE))

# pass argument to grep()
# note, if invert = TRUE the selected subset is inverted
# and all species not matching 'Carex' are retained!
taxon(subset(x, "carex", invert = TRUE, ignore.case = TRUE))

# alternative if taxonomy(x)$abbr has meaningful abbreviations
taxon(x[ , grep("care", colnames(x)) ])

# numeric index to define subset
i <- sample(1:length(taxon(x)), 10)
colnames(subset(x, i)) # colnames() displays column names of as.matrix(x)

# some more usage examples
# subset object such that only the set of species of the most species rich
# sample remain
res <- subset(x, taxon(x[ which.max(richness(x, "sample")), ]))
dim(res)

# set of species that occur in all relevees (plots)
res <- subset(x, taxon(x[, colSums(x) == nrow(x) ]))
dim(res)

# logical index to define subset
# get family retrieved from the plant list
## Not run: 
library(Taxonstand)
tmp <- TPL(taxon(x))
# Carex is a genus of Cyperaceae, let's see if there are more members of
# this family
taxon(subset(x, tmp$Family == "Cyperaceae")) # no, there are not

## End(Not run)

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