Skip to content

Instantly share code, notes, and snippets.

Created March 30, 2015 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/93e346f551b8cb5e0472 to your computer and use it in GitHub Desktop.
Save anonymous/93e346f551b8cb5e0472 to your computer and use it in GitHub Desktop.
Generate a vector full of strings ("words"), repeated in groups. Useful for creating factor labels when testing analysis routines.
# Create 2 replicates of 5 "words" generated from random characters,
# each "word" 5 - 15 characters long, with word length following a
# poisson distribution.
rep(replicate(5, paste(sample(letters, round(rpois(5000, lambda = 3)+5, 0), replace = FALSE), collapse = "")), 2)
# Sample output:
# [1] "rfexnwyjst" "vwtadhjnly" "ztfgvldo" "tmerol" "mcqhosap" "rfexnwyjst" "vwtadhjnly" "ztfgvldo" "tmerol"
#[10] "mcqhosap"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment