Returns the upper left or lower right part of a spam object.

# S4 method for spam
head(x, n = 6L, m = n, ...)
# S4 method for spam
tail(x, n = 6L, m = n, addrownums = TRUE, ...)

Arguments

x

a spam object

n

a single integer. If positive, size for the resulting object: number of elements for a vector (including lists), rows for a matrix or data frame or lines for a function. If negative, all but the n last/first number of elements of x.

m

similar to n but for the number of columns.

addrownums

create row and column namves them from the selected elements.

...

arguments to be passed to or from other methods.

Details

For matrices, 2-dim tables and data frames, head() (tail()) returns the first (last) n rows and m columns when n > 0 or all but the last (first) n rows when n < 0 (with similar behavior for m).

tail() will add row and column names of the form "[n,]" and "[,n]" to the result, so that it looks similar to the last lines and columns of x when printed. Setting addrownums = FALSE suppresses this behaviour.

A method for spam.chol.NgPeyton objects is exported as well.

Value

An regular matrix.

Author

Reinhard Furrer

Examples

head( precmat.RW2( 10))
#>      [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,]    1   -2    1    0    0    0
#> [2,]   -2    5   -4    1    0    0
#> [3,]    1   -4    6   -4    1    0
#> [4,]    0    1   -4    6   -4    1
#> [5,]    0    0    1   -4    6   -4
#> [6,]    0    0    0    1   -4    6
tail( precmat.season(n=10, season=3), n=4, m=10)
#>       [,7] [,8] [,9] [,10]
#> [7,]     3    2    1     0
#> [8,]     2    3    2     1
#> [9,]     1    2    2     1
#> [10,]    0    1    1     1