rep_mat: Repeat object column-wise and row-wise

Description Usage Arguments Value Examples

View source: R/rep_mat.R

Description

Repeat object column-wise and row-wise

Usage

1
2
3
4
5
rep_mat(obj, n = c(nrows, ncols), ncols = 1, nrows = 1)

rep_cols(obj, ncols = 1)

rep_rows(obj, nrows = 1)

Arguments

obj

An object to be repeated (a matrix, a vector, ...).

n

(vector of 2 integers | integer) a number of repetitions row-wise and column-wise. If one integer may be indicated, it is treated as nrows.

ncols

(integer) a number of repetitions column-wise. Ignored if second element of n is provided.

nrows

(integer) a number of repetitions row-wise. Ignored if n is provided.

Value

The same object, repeated column-wise and row-wise.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(spMisc)

M <- matrix(1:4,2,2)

# These pairs of functions do the same:
     rep_mat(M, c(2,3))
     rep_mat(M, 2, 3)

     rep_mat(M, ncols = 2)
     rep_cols(M, 2)

     rep_mat(M, nrows = 2)
     rep_rows(M, 2)

GegznaV/spMisc documentation built on April 26, 2020, 5:59 p.m.