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.534967 0.534967 0.104294 0.104294 0.464132 0.464132
#> [2,] 0.511822 0.511822 0.917442 0.917442 0.575436 0.575436
#> [3,] 0.680444 0.680444 0.837893 0.837893 0.973133 0.973133
#> [4,] 0.456450 0.456450 0.546779 0.546779 0.507591 0.507591