Description Usage Arguments Details Value Warning Author(s) See Also Examples
Coerce object a 'Vegsoup*'
object to other class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## S4 method for signature 'Vegsoup,matrix'
coerce(from,to,strict = TRUE)
## S4 method for signature 'Vegsoup,array'
coerce(from,to,strict = TRUE)
## S4 method for signature 'Vegsoup,dist'
coerce(from,to,strict = TRUE)
## S4 method for signature 'Vegsoup,sparseMatrix'
coerce(from,to,strict = TRUE)
## S4 method for signature 'Vegsoup,dsparseMatrix'
coerce(from,to,strict = TRUE)
## S4 method for signature 'Vegsoup,list'
coerce(from,to,strict = TRUE)
## S4 method for signature 'Vegsoup,data.frame'
coerce(from,to,strict = TRUE)
#\S4method{coerce}{Vegsoup,data.list}(from,to,strict = TRUE)
## S4 method for signature 'Vegsoup,mefa'
coerce(from,to,strict = TRUE)
## S4 method for signature 'Vegsoup,SpatialPoints'
coerce(from,to,strict = TRUE)
## S4 method for signature 'Vegsoup,SpatialPointsDataFrame'
coerce(from,to,strict = TRUE)
## S4 method for signature 'coenocline,Vegsoup'
coerce(from,to,strict = TRUE)
|
from |
A Vegsoup* object. |
to |
class to coerce to. |
strict |
If TRUE, the returned object must be strictly from the target class. |
These are generic coerce methods to ensure that S3 functions dispatch
properly, especially regarding the as(x, "matrix")
and as(x,
"dist")
coercion methods. In this way it is almost always possible to
supply a 'Vegsoup*'
object directly to functions for multivariate
analysis (see ‘Examples’). Note, the matrix coercion retrieves a
species matrix according to the defaults of as.matrix
and the
list coercion calls as.matrix(x, typeof = "character", mode = "Q")
.
Coercion to sparse matrices is currently rather limited.
Coercion to 'matrix'
and 'sparseMatrix'
returns an object of the corresponding class.
Coercion to 'list' returns a list with three components.
species |
object of class |
sites |
object of class |
taxonomy |
object of class |
Coercion to 'data.frame' returns a "data.frame"
with as many row as
there are in species(x)
.
Coercion to 'array' returns an "array"
.
Coercion to 'mefa' and 'data.list' returns a "mefa"
respectively
"data.list"
object.
S3 functions must contain a call to as.matrix
to guarantee dispatch.
For example metaMDS(obj)
does not work, but other functions in
package vegan will. Note, if a function that expects a species matrix calls
as.data.frame
in the function body it will certainly break, because
the as.data.frame(x)
coercion does not return a species matrix (see
as.data.frame
)!
Coercion to class "mefa"
is only meaningful for count data!
Roland Kaiser
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 | require(vegsoup)
require(cluster)
data(barmstein)
x <- barmstein
# same as as.matrix(prt, typeof = "numeric")
m <- as(x, "matrix")
# the species matrix as an multi-dimensional array
a <- as(x, "array")
# the data stored in slots 'species', 'sites' and 'taxonomy'
l <- as(x, "list")
length(l)
# coerce to data.list in package multitable
# package multitable was removed from the CRAN (2016-05-02)
# xdl <- as(x, "data.list")
# summary(xdl)
# automatic dispatch of Vegsoup* object as argument in S3 function
# if they internally call as.matrix or as.dist
decostand(x) <- "hellinger"
vegdist(x) <- "euclidean"
rda(x) # principal component analysis
agnes(x) # agglomerative nesting
# no call to as.dist(d) in hclust, no automatic dispatch
hclust(as.dist(x))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.