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.0342413 0.4035381 0.289892
#> [2,] 0.0342413 0.4035381 0.289892
#> [3,] 0.3203857 0.0636615 0.678380
#> [4,] 0.3203857 0.0636615 0.678380
#> [5,] 0.4023282 0.3887013 0.735320
#> [6,] 0.4023282 0.3887013 0.735320
#> [7,] 0.1956698 0.9755478 0.195957
#> [8,] 0.1956698 0.9755478 0.195957