[R] sample "n" random positions from a matrix

Paul Smith phhs80 at gmail.com
Sun Dec 10 21:22:43 CET 2006


On 12/10/06, Milton Cezar Ribeiro <milton_ruser at yahoo.com.br> wrote:
>   I have a binary matrix (dim 100x100) filled with values 0 and 1. I need select a record "n" positions of that matrix when values are 1. How can I do that?

Do you mean extracting the indexes of n randomly chosen elements of
the matrix which are equal to one?

Paul




More information about the R-help mailing list