How can I take a sample of n random points from a matrix populated with 1's and 0's ?
a=rep(0:1,5)b=rep(0,10)c=rep(1,10)dataset=matrix(cbind(a,b,c),nrow=10,ncol=3)dataset [,1] [,2] [,3] [1,] 0 0 1 [2,] 1 0 1 [3,] 0 0 1 [4,] 1 0 1 [5,] 0 0 1 [6,] 1 0 1 [7,] 0 0 1 [8,] 1 0 1 [9,] 0 0 1[10,] 1 0 1I want to be sure that the positions(row,col) from were I take the N samples are random.
I know sample {base} but it doesn't seem to allow me to do that, other methods I know are spatial methods that will force me to add x,y and change it to a spatial object and again back to a normal matrix.
More information