Hello all,
I am working with a large matrix, but I am only interested in keeping the nth largest values of every row, making the rest of values equal to 0.
I will use a simple example:
n = 5 # Number of dimensions
A = matrix(runif(n^2), n) # Random matrix example
How could I keep the largest k=2 values of every row, while making the rest of values equal to 0 ?
Thanks in advance for any help!