Code Monkey home page Code Monkey logo

Comments (2)

dbetebenner avatar dbetebenner commented on July 3, 2024 1

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.

aito123 avatar aito123 commented on July 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.