as.data.frame: Coerce to data.frame

Description Usage Arguments Details Author(s) See Also Examples

Description

Besides the as.matrix and alike methods that return just the species matrix of Vegsoup* objects, an essential requirement is the coercion to class "data.frame" for which the plethora of R functions for single-table data becomes available to Vegsoup* objects. Because this coercion is fundamental, the syntax to execute is as simple as possible.

The as.data.frame method for objects of class Sites provides reshaping the data to wide format (cp. stackSites).

Usage

1
2
3
4
5
## S4 method for signature 'Vegsoup'
as.data.frame(x)

## S4 method for signature 'Sites'
as.data.frame(x)

Arguments

x

Vegsoup* object.

Details

For Vegsoup objects, the as.data.frame method is essentially a database join operation. Unlike the data stored in a Vegsoup* object, the returned data frame has redundancy (e.g. as many rows by plot as there are species).

Author(s)

Roland Kaiser

See Also

as.matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
require(vegsoup)
data(barmstein)

#	for Vegsoup objects
class(as(barmstein, "data.frame"))
class(as.data.frame(barmstein))

#	automatic dispatch
summary(lm(hcov ~ scov, data = layers(barmstein, collapse = "E")))

#	for Sites obejcts
#	create a dummy object first
y <- data.frame(
		plot = rep(1:3, each = 3),
		variable = rep(rep(paste0("var", 1:3)), times = 3),
		value = rnorm(3 * 3))

y <- sites(y)

as.data.frame(y)

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