lundi 28 août 2017

Randomly assign different values to rows using different probability in R

Have such a data frame:

ID var
1  NA
2  NA
3  NA
4  NA
...

I need to randomly assign var values of 20% rows to be A, and 30% rows to be B, and 50% rows to be C.

Is there some efficient way to solve this?




Aucun commentaire:

Enregistrer un commentaire