shift.right: Shift matrix n columns to the right

Description Usage Arguments Value Note Author(s) Examples

View source: R/shift.right.R

Description

This function returns a matrix that has been shifted to the right n columns filling the previous columns with the given fill value.

Usage

1
shift.right(A, cols = 1, fill = 0)

Arguments

A

a matrix

cols

integer number of columns to be shifted to the right

fill

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

Example output

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

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