CenterForAssessment / randomNames

Function to generate random gender and ethnicity correct first and/or last names. Names are chosen proportionally based upon their probability of appearing in a large scale data base of real names.
https://centerforassessment.github.io/randomNames
Other
32 stars 6 forks source link

set.seed() only works for the first row of a dataframe. #73

Open cfreder2 opened 2 years ago

cfreder2 commented 2 years ago

Neat package.

One minor thing, running this will result in a different person for the second row of the dataframe. The seed is only respected for the first run.

set.seed(1842) randomNames(2, which.names = "both", return.complete.data = T)

The workaround: set.seed(1842) df1 <- bind_rows(randomNames(1, gender = T, ethnicity = T, which.names = "both", return.complete.data = T), randomNames(1, gender = T, ethnicity = T, which.names = "both", return.complete.data = T), randomNames(1, gender = T, ethnicity = T, which.names = "both", return.complete.data = T))

Any thoughts on allowing us to set the seed so we can always reproduce the same set of names?

dbetebenner commented 2 years ago

Thanks for the comment.

I'm not sure I understand the way in which you want the function to produce results.

When I run your first example

set.seed(1842)
randomNames(2, which.names = "both", return.complete.data = T)

I get

> set.seed(1842)
> randomNames(2, which.names = "both", return.complete.data = T)
   gender ethnicity first_name   last_name
1:      0         6    Annnees al-Muhammad
2:      1         6      Suhaa    el-Basha

If I run it again I get the same thing.

> set.seed(1842)
> randomNames(2, which.names = "both", return.complete.data = T)
   gender ethnicity first_name   last_name
1:      0         6    Annnees al-Muhammad
2:      1         6      Suhaa    el-Basha

I'm not getting a different person for the second row of the dataframe. Can you clarify?