Dear Friends, I have a matrix of size 5000 X 20. The first two columns are indicator variables taking the value of either 0 or 1. Let us call the first two columns Y1 and Y2.
I need to randomly sample 1000 rows with all the associated columns, in other words my new matrix should be of size 1000 X 20. I realize that using this command newmat <- mainmat[sample(1000,replace=F),] achieves this. However, I would like to make sure that both Y1 and Y2 have more or less an equal amount of 0's and 1's. At present when I sample, I get cases where sometimes all my Y2's are 0. Is there any way to accomodate this problem. Thanks in advance. Regards Anup --------------------------------- [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.