Assuming I have the following lists of numbers in R, how can I choose 6 random numbers by specifying the how many I need from each group?
r<-c(1,2,3,4,5,6,7,8,9,10)
b<-c(11,12,13,14,15,16,17,18,19,20)
y<-c(21,22,23,24,25,26,27,28,29,30)
g<-c(31,32,33,34,35,36,37,38,39,40)
How can I select, say 2 random numbers from r, 2 random numbers from b, 1 random number from y and 1 random number from g?
I need my codes to be flexible enough to manually input how many numbers I need from each list. I also want the final output to be just the list of 6 random numbers, based on my selection.
Aucun commentaire:
Enregistrer un commentaire