Suppose we have a dataframe or matrix with one column specifying an integer value N as below (col 5).
Is there a vector approach to repopulate the object such that each row gets copied N times?
> y
[,1] [,2] [,3] [,4] [,5]
[1,] -0.02738267 0.5170621 -0.01644855 0.48830663 1
[2,] -0.30076544 1.8136359 0.02319640 -1.59649330 2
[3,] 1.73447245 0.4043638 -0.29112385 -0.25102988 3
[4,] 0.01025271 -0.4908636 0.80857300 0.08137033 4
The result would be as follows.
[1,] -0.02738267 0.5170621 -0.01644855 0.48830663 1
[2,] -0.30076544 1.8136359 0.02319640 -1.59649330 2
[2,] -0.30076544 1.8136359 0.02319640 -1.59649330 2
[3,] 1.73447245 0.4043638 -0.29112385 -0.25102988 3
[3,] 1.73447245 0.4043638 -0.29112385 -0.25102988 3
[3,] 1.73447245 0.4043638 -0.29112385 -0.25102988 3
[4,] 0.01025271 -0.4908636 0.80857300 0.08137033 4
[4,] 0.01025271 -0.4908636 0.80857300 0.08137033 4
[4,] 0.01025271 -0.4908636 0.80857300 0.08137033 4
[4,] 0.01025271 -0.4908636 0.80857300 0.08137033 4
Another question would be how to jitter the newly populated rows, such that there is not compute overlap of the newly copied data.
Some made-up data:
Just do:
And I am not sure what you mean by “jitter”, but maybe
?