It seems that when the number of names is exhausted when using randomNames() (with sample.with.replacement = FALSE) it gives an uninformative error message about sampling. It would be great if the {randomNames} package could provide the user with an custom informative error message when the requested number of names is too large. This error message can also suggest turning sample.with.replacement to TRUE to help.
Here is a reprex to show an example
library(randomNames)
set.seed(1)
gender <- rep(c("M", "F"), 2525)
names <- randomNames::randomNames(
which.names = "both",
name.sep = " ",
name.order = "first.last",
gender = gender,
sample.with.replacement = FALSE
)
str(names)
#> chr [1:5050] "Sebastian Clayton" "Melisa White" "Eli Jackson" "Malisse Ha" ...
gender <- rep(c("M", "F"), 3000)
names <- randomNames::randomNames(
which.names = "both",
name.sep = " ",
name.order = "first.last",
gender = gender,
sample.with.replacement = FALSE
)
#> Error in sample.int(length(x), size, replace, prob): cannot take a sample larger than the population when 'replace = FALSE'
Created on 2024-01-18 with reprex v2.0.2
It seems that when the number of names is exhausted when using
randomNames()(withsample.with.replacement = FALSE) it gives an uninformative error message about sampling. It would be great if the {randomNames} package could provide the user with an custom informative error message when the requested number of names is too large. This error message can also suggest turningsample.with.replacementtoTRUEto help.Here is a reprex to show an example
Created on 2024-01-18 with reprex v2.0.2