jeudi 23 janvier 2020

R row-wise runif() between 2 columns

I have the following data frame DF :

Min Max
10  20
14  34
9   29
... ...

and want to add a new column that samples a number between Min and Max of each row with uniform distribution. I've tried the below but give me the same number for all rows, meaning it's not sampling row by row as desired:

DF$random <- runif(1,min=DF$Min,max=DF$Max)

How may I achieve this?




Aucun commentaire:

Enregistrer un commentaire