Ids based on a number of adjectives and an animal

adjective_animal(
  n = 1,
  n_adjectives = 1,
  style = "snake",
  max_len = Inf,
  alliterate = FALSE,
  global = TRUE,
  use_openssl = NULL
)

Arguments

n

number of ids to return. If NULL, it instead returns the generating function

n_adjectives

Number of adjectives to prefix the animal with

style

Style to join words with. Can be one of "Pascal", "camel", "snake", "kebab", "dot", "title", "sentence", "lower", "upper", "constant" or "spongemock"

max_len

The maximum length of a word part to include (this may be useful because some of the names are rather long. This stops you generating a hexakosioihexekontahexaphobic_queenalexandrasbirdwingbutterfly). A vector of length 2 can be passed in here in which case the first element will apply to the adjectives (all of them) and the second element will apply to the animals.

alliterate

Produce "alliterative" adjective animals (e.g., hessian_hamster). Note that this cannot provide an equal probability of any particular combination because it forces a weighted sampling. Adjectives may also be repeated if n_adjectives is more than 1.

global

Use global random number generator that responds to set.seed (see random_id for details, but note that the default here is different).

use_openssl

Use openssl for random number generation when using a non-global generator (see random_id for details)

Details

The list of adjectives and animals comes from https://github.com/a-type/adjective-adjective-animal, and in turn from <gfycat.com>

Author

Rich FitzJohn

Examples

# Generate a random identifier:
ids::adjective_animal()
#> [1] "moving_wreckfish"

# Generate a bunch all at once:
ids::adjective_animal(5)
#> [1] "arachnophobic_stork"                 
#> [2] "bioecological_baleenwhale"           
#> [3] "ultrashort_oregonsilverspotbutterfly"
#> [4] "incendiary_leopard"                  
#> [5] "engaging_beagle"                     

# Control the style of punctuation with the style argument:
ids::adjective_animal(style = "lower")
#> [1] "significant kitfox"
ids::adjective_animal(style = "CONSTANT")
#> [1] "IMMOBILE_HOCHSTETTERSFROG"
ids::adjective_animal(style = "camel")
#> [1] "unrivaledBedlingtonterrier"
ids::adjective_animal(style = "kebab")
#> [1] "winning-newfoundlanddog"
ids::adjective_animal(style = "spongemock")
#> [1] "cHuFfY-hErAlD"

# Control the number of adjectives used
ids::adjective_animal(n_adjectives = 3)
#> [1] "loathful_semimythical_frail_dipper"

# This can get out of hand quickly though:
ids::adjective_animal(n_adjectives = 7)
#> [1] "textile_pristine_centralistic_benevolent_benignant_dejected_spiniferous_bluewhale"

# Limit the length of adjectives and animals used:
ids::adjective_animal(10, max_len = 6)
#>  [1] "black_hogget" "robo_clam"    "petite_adder" "poorly_cobra" "keen_eider"  
#>  [6] "mutual_lion"  "dozing_molly" "ok_rook"      "airy_jackal"  "catty_hackee"

# The lengths can be controlled for adjectives and animals
# separately, with Inf meaning no limit:
ids::adjective_animal(10, max_len = c(6, Inf), n_adjectives = 2)
#>  [1] "damp_bald_turtledove"        "clotty_manly_noctule"       
#>  [3] "pasty_awful_chickadee"       "dotted_winded_iberiannase"  
#>  [5] "fixed_brown_goshawk"         "meaty_minute_japanesebeetle"
#>  [7] "unreal_blond_ewe"            "ardent_devoid_buzzard"      
#>  [9] "elfish_angry_lovebird"       "stable_young_megalosaurus"  

# Pass n = NULL to bind arguments to a function
id <- ids::adjective_animal(NULL, n_adjectives = 2,
                            style = "dot", max_len = 6)
id()
#> [1] "sickly.empty.fossa"
id(10)
#>  [1] "frigid.cosy.jackal"   "stunty.lame.bluet"    "bald.epoxy.upupa"    
#>  [4] "fuzzy.coarse.discus"  "torrid.vernal.brant"  "ardent.crabby.emu"   
#>  [7] "macho.petite.kid"     "lapis.busied.rabbit"  "elvish.savage.rodent"
#> [10] "foxy.futile.elver"   

# Alliterated adjective animals always aid added awesomeness
ids::adjective_animal(10, n_adjectives = 3, alliterate = TRUE)
#>  [1] "artistic_ash_aimless_amberpenshell"                  
#>  [2] "coquettish_constitutive_compentant_crustacean"       
#>  [3] "silly_selfcentered_slender_stegosaurus"              
#>  [4] "awestricken_antitoxic_alkalizable_arrowcrab"         
#>  [5] "surah_suede_selfevolved_seaslug"                     
#>  [6] "connectible_continuous_condensed_coral"              
#>  [7] "complacent_coffeecolored_coplanar_cheetah"           
#>  [8] "harebrained_holohedral_holy_harlequinbug"            
#>  [9] "carroty_consentient_combustive_coral"                
#> [10] "aichmophobic_amphisbaenic_asbestoid_atlanticbluetang"