jeudi 17 janvier 2019

Random selection of row after subsetting

I have a 10x3 NA matrix that fills one random row with random numbers between 1-100. I want to select another random row (without replacement so to speak) and fill it without knowing which row was initially filled. I am unsure how to go about the second selection. I figure I will have to find a way to subset to just rows with NA and then randomly select. If you need detail please let me know.

myData <- matrix(data = NA,10,3)
random row selection.
myData[sample(1:10,size = 1,),] <- c(sample(1:100,size = 1,replace = TRUE),sample(1:100,size = 1,replace = TRUE),sample(1:100,size = 1,replace = TRUE))

          

Unsure of second random selection




Aucun commentaire:

Enregistrer un commentaire