I want to generate the same random number for groups. Unfortunately, my following code generates random number for each row.
randomised <- data %>% group_by(`ID`)%>% mutate(random = sample(1:100,n(), replace = TRUE))
Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire