Repeat matrix object respectively to its shape and orientation

crep(x, times)

rrep(x, times)

Arguments

x

matrix

times

number of repetitions

Value

matrix

Details

crep = columnwise repetition

rrep = rowwise repetition

Examples

# Columnwise repetition crep(v(1:3), 4)
#> [,1] [,2] [,3] [,4] #> [1,] 1 1 1 1 #> [2,] 2 2 2 2 #> [3,] 3 3 3 3
crep(t(v(1:5)), 4)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] #> [1,] 1 2 3 4 5 1 2 3 4 5 1 2 3 4 #> [,15] [,16] [,17] [,18] [,19] [,20] #> [1,] 5 1 2 3 4 5
# Rowwise repetition rrep(v(1:3), 4)
#> [,1] #> [1,] 1 #> [2,] 2 #> [3,] 3 #> [4,] 1 #> [5,] 2 #> [6,] 3 #> [7,] 1 #> [8,] 2 #> [9,] 3 #> [10,] 1 #> [11,] 2 #> [12,] 3
rrep(t(v(1:5)), 4)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 2 3 4 5 #> [2,] 1 2 3 4 5 #> [3,] 1 2 3 4 5 #> [4,] 1 2 3 4 5