I have a tibble with 100 points in R, below:
preds <- tibble(x=1:100, y=seq(from=0.01,to=1,by=0.01))
And I want to randomly sample 20 observations with values less than 0.5. Currently, I can select the first 20 observations by:
number_of_likely_negatives<-20
likely_negatives <- preds %>%
arrange(y) %>%
slice(1:number_of_likely_negatives)
But how can I randomly select 20 observations with y values below 0.5?
Aucun commentaire:
Enregistrer un commentaire