I have to solve a question for a class where I have to create a vektor vek1 of length = 60 with twice as many "a" than "b" entries using rep().
My solution is:`
x <- c("a", "a", "b")
vek1 <- rep(x,each = 1, length.out = 60)
Is there a more beautiful and effective solution to solve the question?
rep(rep(c('a', 'b'), c(2, 1)), length.out=60)
This wouldn't probably be my first choice but what I like about this solution is that it uses exactly the information from your question: the two letters, their proportion and the vector length.