1

New to R so not really sure what I'm looking, but I guess purrr could do this for me.

How could I create this vector:

c <- c("cookie", "cookie", "cookie", "cookie", "dog", "dog", "dog")

from this:

a <- 4
b <- 3
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
stapperen
  • 137
  • 1
  • 9

1 Answers1

2

Use rep

rep(c("cookie","dog"),c(a,b))
Jim Chen
  • 3,262
  • 3
  • 21
  • 35