shift.up: Shift matrix m rows up

Description Usage Arguments Value Note Author(s) Examples

View source: R/shift.up.R

Description

This function returns a matrix where the argument as been shifted up the given number of rows filling the bottom rows with the given fill value.

Usage

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

Arguments

A

a matrix

rows

integer number of rows

fill

fill value which as the default value of 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.up( A, 1 )
shift.up( A, 3 )

Example output

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

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