i have 2 vectors:
presidents = c("bill clinton", "george bush", "ronald reagan", "jimmy carter", "gerald ford") vice.presidents = vice.presidents = c("al gore", "dan quayle", "george bush","walter mondale", "nelson rockefeller")
i trying results using substr()
of form "clinton+quayle", "bush+..."
last names , randomly selected president paired randomly selected vice president.
try following.
set.seed(1843) p <- sapply(strsplit(presidents, " "), '[', 2) vp <- sapply(strsplit(vice.presidents, " "), '[', 2) n <- 5 paste(sample(p, n, true), sample(vp, n, true))
first, split names white-space , keep 2nd part, last name.
then, sample @ random result vectors , paste them together.
Comments
Post a Comment