I would like to randomly re-order the rows of matrix A to generate another new matrix. How to do that in R?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
sample()to generate row-indices in a (pseudo-)random order and reorder the matrix using[.Giving
Next, generate a random order for the rows
This gives gives
Now use that to reorder
A