Hello, all, I'm learning to do randomized distributions in my Stats 101 class*. I thought I could do it with a call to sample() inside a matrix(), like:
> matrix(sample(1:10, replace=TRUE), 5, 10, byrow=TRUE) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 8 2 3 1 8 2 8 8 9 8 [2,] 8 2 3 1 8 2 8 8 9 8 [3,] 8 2 3 1 8 2 8 8 9 8 [4,] 8 2 3 1 8 2 8 8 9 8 [5,] 8 2 3 1 8 2 8 8 9 8 > Imagine my surprise to learn that all the rows were the same permutation. I thought each time sample() was called inside the matrix, it would generate a different permutation. I modeled this after the bootstrap sample techniques in https://pages.stat.wisc.edu/~larget/stat302/chap3.pdf. I don't understand why it works in bootstrap samples (with replace=TRUE), but not in randomized distributions (with replace=FALSE). Thanks for any insight you can share with me, and any suggestions for getting rows in a matrix with different permutations. -Kevin *No, this isn't a homework problem. We're using Lock5 as the text in class, along with its StatKey web application. I'm just trying to get more out of the class by also solving our problems using R, for which I'm not receiving any class credit. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.