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

rep_rows(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 type of the input

Examples

test_matrix <- matrix(runif(12), 4)
rep_rows(test_matrix, 2)
#>          [,1]      [,2]      [,3]
#> [1,] 0.820669 0.4491990 0.5285930
#> [2,] 0.820669 0.4491990 0.5285930
#> [3,] 0.810927 0.6165436 0.9467974
#> [4,] 0.810927 0.6165436 0.9467974
#> [5,] 0.640569 0.0575007 0.0211544
#> [6,] 0.640569 0.0575007 0.0211544
#> [7,] 0.899209 0.4415296 0.3525142
#> [8,] 0.899209 0.4415296 0.3525142