R replicate elements based on its index
Given a matrix,
x<-matrix(rnorm(4))
How can I do the following
So row 1's element will get replicated by 1 time, row 2's element by 2
times, etc...
I tried to do it with 'rep' and loop but its really slow if the matrix is
large.
No comments:
Post a Comment