Coercion.Rd
Coercion of spam
matrices to proper vector objects
# S4 method for spam
as.vector(x, mode = "any")
spam object.
character string naming an atomic mode or "any"
/"list"
/"expression"
.
If structurebased=TRUE
, the vector x@entries
.
Conversely, if structurebased=FALSE
, the result is identical to
one with as.vector(as.matrix(x))
.
This coercion allows smooth transitions between different
matrix formats, see example below.
The Cholesky factors are first transformed to a spam
object.
x <- diag(2)
ifelse( x, x, 1-x)
#> [,1] [,2]
#> [1,] 1 1
#> [2,] 1 1
ifelse( x, as.vector(x), 1-as.vector(x))
#> [,1] [,2]
#> [1,] 1 1
#> [2,] 1 1
x <- diag.spam(2)
options(spam.structurebased=FALSE)
ifelse( x, as.vector(x), 1-as.vector(x))
#> [1] 1 1 1 1
options(spam.structurebased=TRUE)
ifelse( x, as.vector(x), 1-as.vector(x))
#> [1] 1 1