[R] Interlacing two vectors

Murray Jorgensen maj at stats.waikato.ac.nz
Wed Aug 20 23:16:26 CEST 2003


I want to interlace two vectors. This I can do:

 > x <- 1:4
 > z <- x+0.5
 > as.vector(t(cbind(x,z)))
[1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5

but this seems rather inelegant. Any suggestions?

Murray

-- 
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz                                Fax 7 838 4155
Phone  +64 7 838 4773 wk    +64 7 849 6486 home    Mobile 021 1395 862




More information about the R-help mailing list