shift.down: Shift matrix m rows down

Description Usage Arguments Value Note Author(s) Examples

View source: R/shift.down.R

Description

This function returns a matrix that has had its rows shifted downwards filling the above rows with the given fill value.

Usage

1
shift.down(A, rows = 1, fill = 0)

Arguments

A

a matrix

rows

the number of rows to be shifted

fill

the fill value which as a default is zero

Value

A matrix.

Note

If the argument A is not a numeric matrix, then the function presents an error message and stops. If the argument rows is not a positive integer, then the function presents an error message and stops.

Author(s)

Frederick Novomestky fnovomes@poly.edu

Examples

1
2
3
A <- matrix( seq( 1, 16, 1 ), nrow=4, byrow=TRUE )
shift.down( A, 1 )
shift.down( A, 3 )

Example output

     [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    1    2    3    4
[3,]    5    6    7    8
[4,]    9   10   11   12
     [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    1    2    3    4

matrixcalc documentation built on May 2, 2019, 1:45 p.m.