Repeats each column of the matrix or data frame 'x' a number of times equal to 'times'.

rep_cols(x, times)

Arguments

x

A matrix or data frame

times

An integer indicating the number of times to repeat the row/column

Value

A matrix or data.frame depending on the type of the input

Examples

test_matrix <- matrix(runif(12), 4)
rep_cols(test_matrix, 2)
#>          [,1]     [,2]     [,3]     [,4]      [,5]      [,6]
#> [1,] 0.444305 0.444305 0.516790 0.516790 0.0843002 0.0843002
#> [2,] 0.448517 0.448517 0.559078 0.559078 0.1246694 0.1246694
#> [3,] 0.440841 0.440841 0.232954 0.232954 0.7280718 0.7280718
#> [4,] 0.246050 0.246050 0.692554 0.692554 0.1673798 0.1673798