Created
March 30, 2015 00:13
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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