names: Row and Column Names of 'Vegsoup*' objects

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

Description

Retrieve the row or column names of the species matrix (see as.matrix) or the names of the sites data (see sites). Note, the species matrix and the sites data frame relate to each other by a 1:1 data base schema. Therefore, rownames(x) (matrix method) and row.names(x) (data.frame method) return the same and the second method just exists for completeness.

Usage

 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
## slot 'species'

## S4 method for signature 'Vegsoup'
dimnames(x)

## S4 method for signature 'Vegsoup'
rownames(x, do.NULL = TRUE, prefix = "row")

## S4 method for signature 'Vegsoup'
colnames(x, do.NULL = TRUE, prefix = "col")

## S4 replacement method for signature 'Vegsoup'
rownames(x) <- value

## S4 method for signature 'Vegsoup'
row.names(x)

## S4 method for signature 'Vegsoup'
names(x)

## S4 method for signature 'Vegsoup'
x$name

## slot 'sites'
## S4 replacement method for signature 'Vegsoup'
row.names(x) <- value

## S4 replacement method for signature 'Vegsoup'
names(x) <- value

## S4 replacement method for signature 'Vegsoup'
row.names(x) <- value

## S4 replacement method for signature 'Vegsoup'
x$name <- value

Arguments

x

Vegsoup* object.

name

character. Literal character string or a name.

do.NULL

not used.

prefix

not used.

value

character or integer vector of the same length as rownames(x), or NULL.

Details

Function dimnames returns dimnames(as.matrix(x)). Correspondingly, colnames equals dimnames(as.matrix(x))[ [2] ]. This applies only to the species matrix which is of class matrix. Note, function names if called on an object of class matrix will return NULL in base R. Therefore the names method is only defined for the sites slot and equals names(sites(x)). As both, the species matrix and the sites data frame, have the same number of rows (plots) in exactly the same order, the rownames and row.names methods return identical values for both data partitions (matrices and data.frames respectively).

The "$" operator can be used to access columns of the sites slot which is of class data.frame by name and has also functions to get or set the names of the object. Indexing of the species matrix can be done using indices specifying elements to extract. See ‘Examples’.

Note

Assigment of new rownames can be dangerous and should only be performed with care! Of course, valid rownames must have no duplicates nor missing values.

Author(s)

Roland Kaiser

See Also

taxon

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
require(vegsoup)

data(barmstein)
x <- barmstein

# access dimnames of species matrix (class 'matrix')
colnames(x) # species-layer replicates
rownames(x) # plot names
dimnames(x)

# return names of sites data (class 'data.frame')
names(x)
row.names(x)

# access names of sites data
x$rock

# set a name
names(x)[1] <- "bar"

# assign a value
if (any(names(x) == "rock")) {
   x$rock <- sqrt(x$rock)
}

# return plot names
rownames(x)

# assign new rownames
rownames(x) <- paste("new", rownames(x), sep = ".")

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