Comments (2)
Thanks for the suggestion. This could get complicated. Given that there isn't an endless supply of names in the internal dataset, requests for certain initial.letter, gender, ethnicity combinations would likely yield no names or repeats.
Consider the following wrapper function:
firstLetter <- function(tmp_data, first_letter, count) {
sample(tmp_data[first_letter==substr(tmp_data, start=1, stop=1)], count, replace=TRUE)
}
firstLetter(randomNames(n=5000, gender=1, ethnicity = 4, which.names="first"), first_letter="Q", count=5)
> firstLetter(randomNames(n=5000, gender=1, ethnicity = 4, which.names="first"), first_letter="Q", count=5)
[1] "Quanisha" "Quetzally" "Quetzally" "Quetzally" "Quanisha"
There are (it seems) only about 3 unique gender=1 ethnicity=4 names that start with a Q.
I have to ask for 5000 names so that I get enough names so that there is actually one containing Q.
Is this what you're (roughly) looking to do?
from randomnames.
Amazing, thank you very much. This is what i was looking for (roughly) speaking. Though it would be amazing a parameter for a initial.letter=
, i understand that maybe the database does not have the same amount of names per letter. Anyway, greatful for your answer. Greetings from Perรบ.
from randomnames.
Related Issues (17)
- randomNames(0) returns more than 'n' random first and/or last names. HOT 1
- offer option to sample without replacement HOT 1
- `sample.with.replacement = FALSE` across ethnicities/ genders HOT 2
- Handle NAs in randomNames()'s gender argument HOT 3
- firstnames weighted by birth year? HOT 1
- Error message populating out even though the package runs fine HOT 3
- Random Error with large samples without replacement HOT 2
- data source? HOT 1
- Leading whitespaces in some names HOT 2
- set.seed() only works for the first row of a dataframe. HOT 1
- Are the first and second names independent or associated
- Partial argument matching in `rep()`
- Uninformative error message when exhausting names HOT 2
- Plans to expand database of names? HOT 1
- Anonymize name across multiple records
- New package version & CRAN release? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from randomnames.