I have a vector, say vec = c(1,3,2)
. I want to insert a value, e.g., -1, after each of the value, so that to get c(1,-1,3,-1,2,-1)
. How to achieve that with some simple function?
Asked
Active
Viewed 28 times
0

yliueagle
- 1,191
- 1
- 7
- 22
-
2Try: `as.vector(rbind(vec,-1))` – nicola Jan 29 '15 at 10:30
-
See http://stackoverflow.com/questions/12044616/alternate-interweave-or-interlace-two-vectors – mnel Jan 29 '15 at 10:32