Sites-class: Sites Class

Description Objects from the Class Slots Methods Author(s) See Also Examples

Description

Data representation of sites data in long format where each observation on a particular plot (environmental variables, stand parameters) is represented by one row. Note, the initialize method of the class performs ordering, first by plot and then by variable.

Objects from the Class

Objects can be created by calls of the form new("Sites", ...), where ... expands to slot 'data'. Using the sites method with appropriate objects is also convenient (see ‘Methods’). Function stackSites is useful when the data is in wide format (plot by variable matrix).

Slots

data:

Object of class 'data.frame'.

The slot data holds a 'data.frame' with three columns, all of character type and with names "plot", "variable", and "value". The meaning of these columns is as detailed below:

Methods

sites

There exists sites methods for a number of R base classes.

signature(obj = "data.frame"): promote data.frame to object of class 'Sites'

signature(obj = "matrix"): promote matrix to object of class 'Sites' Note, obj does not need to have dimnames.

signature(obj = "character"): supply a file to be read by read.csv and promote that object to class Sites. Remember to pass appropriate arguments to read.csv that meet the specifications of your file (e.g. argument sep).

Sites class has also a sites method.

signature(obj = "Sites"): accessor function for slot 'data'.

signature(obj = "VergsoupVerbatim"): promote "VegsoupVerbatim" object to class Sites.

$

signature(x = "Sites"): retrieve column by name (see ‘Slots’).

[

signature(x = "Sites"): subset parts of an object. Note, only subsetting by rows is currently implemented due to the class inherent data model.

variable

signature(x = "Sites"): retrieves the values for a given variable. The method returns NA for plots missing that variable. If the variable is not present, the method returns NULL. The class stores the values for each variable as character type. Therefore, you may want to use type.convert(variable(obj, name)) if you expect numbers.

variable<-

signature(x = "Sites"): sets the values for a given variable..

variables

signature(x = "Sites"): retrieves the unique set of variables as a character vector. Useful for inspectino of the objects contents.

nrow

signature(x = "Sites"): the number of rows. Each plot and variable combination constitutes a row.

bind

signature(x = "Sites"): bind method to combine two or more objects.

coordinates

signature(x = "Sites"): method to retrieve matrix of coordinates from object. The method assumes to find values for variables longitude and latitude. If not present a random pattern is returned.

Author(s)

Roland Kaiser

See Also

stackSites Species 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
showClass("Sites")

data(barmstein)

# extract from Vegsoup object for demonstration
# get slot 'sites', a 'data.frame' in wide format
s <- sites(barmstein)

# add column plot to match default schema of stackSites
s <- cbind(plot = rownames(s), s)
class(s)

# promote to class Sites
s <- stackSites(s)

# get slot 'data' from object of class 'Sites'
s <- sites(s)
class(s)

# matrix method 
s <- as.matrix(s)
s <- sites(s)

# combine objects
data(windsfeld)

# another roundabout to demonstrate reshaping
# from wide to long format and vice versa
# we get the example again from the slot 'sites'
s2 <- cbind(plot = rownames(windsfeld), sites(windsfeld))

# stack, convert to long format
s2 <- stackSites(s2)

# 'data.frame' method for class 'Sites' again reshapes to wide format
s2 <- as.data.frame(s2)

# bind demands a 'Sites' object, so we turn it back again
s2 <- stackSites(data.frame(plot = rownames(s2), s2))

# now we bind objects
bind(s, s2)

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