When I perform:
a <- seq(1,1.5,0.1)
b <- c(1,1.1,1.4,1.5)
x <- rep(c(a,b),times=c(2,1))
Error in rep(c(a, b), c(2, 1)) : invalid 'times' argument
Why?
When we concatenate (c
) two vectors, it becomes a single vector. If the idea would be to replicate 'a' by 2 and 'b' by 1, we place them in a list
, and use rep
. The output will be a list
, which can be unlist
ed to get a vector
.
unlist(rep(list(a,b), c(2,1)))