vendredi 25 juin 2021

Select random number within range as a new column

I am trying to create a new column of values in a dataframe that would be a random number within a range. As an example:

min <- sample(1:10, 10)
max <- sample(11:20, 10)

dt <- data.frame(min=min, max=max)

dt$value <- sample(dt$min:dt$max,1)

This gives me an error message.

How would I do this? Thank you




Aucun commentaire:

Enregistrer un commentaire