Closed swestenb closed 7 years ago
Update: Can be fixed by setting replace=TRUE
when drawing names within the r_data_frame
function. This code works:
df = r_data_frame(
n = 500,
name(replace=TRUE),
id,
race,
age,
sex,
hour,
iq,
height,
died
)
View(df)
This is because the name vector included in the package is only of length 331. You can either use a smaller n or use name(replace=TRUE)
.
@swestenb @mattsigal I'd appreciate a pull request with a longer name vector. This issue comes up often.
@trinker, seems reasonable to expand that list. Looking at the documentation for the dataset, you would prefer them to be gender-neutral (but then again, looking at the dataset itself - I've never met a female Matthew or Walter)?
In https://github.com/trinker/wakefield/pull/19 I have provided a much more extensive list of names (length = 95025). These pertain to the unique entries found in the babynames package (https://cran.r-project.org/web/packages/babynames/).
@mattsigal Thanks for the PR! I'm closing this issue now.
The following code produces an error:
Error Produced:
Error in sample.int(length(x), size, replace, prob) : cannot take a sample larger than the population when 'replace = FALSE'
This code however works just fine: