samedi 6 février 2021

calculate a new variable with random numbers

I’m pretty sure that the solution to my problem must be VERY easy, but I really got stuck in this. A simple df:

df <- data.frame(
  "v1" = c(0.1, 0.2,0.6,0.8))

I want to calculate a new variable that is a random number from a uniform distribution with min=0 and max=v1. I’m using runif(), but I got the same result for each value of the new variable. Thank you in advance!




Aucun commentaire:

Enregistrer un commentaire