Coercion {spam} | R Documentation

## Coercion to a Vector

### Description

Coercion of `spam` matrices to proper vector objects

### Usage

    ## S4 method for signature 'spam'
    as.vector(x, mode = "any")

### Arguments

`x` | spam object.
`mode` | character string naming an atomic mode or `"any"`/`"list"`/`"expression"`.

### Details

This coercion allows smooth transitions between different matrix formats, see example below.
The Cholesky factors are first transformed to a `spam` object.

### Value

If `structurebased=TRUE`, the vector `x@entries`.
Conversely, if `structurebased=FALSE`, the result is identical to one with `as.vector(as.matrix(x))`.

### Author(s)

Reinhard Furrer

### See Also

`spam.options`

### Examples

    x <- diag(2)
    ifelse( x, x, 1-x)
    ifelse( x, as.vector(x), 1-as.vector(x))

    x <- diag.spam(2)
    options(spam.structurebased=FALSE)
    ifelse( x, as.vector(x), 1-as.vector(x))
    options(spam.structurebased=TRUE)
    ifelse( x, as.vector(x), 1-as.vector(x))

[Package spam version 2.2-2 Index]