[R] Interlacing two vectors
    Peter Dalgaard BSA 
    p.dalgaard at biostat.ku.dk
       
    Wed Aug 20 23:35:26 CEST 2003
    
    
  
Murray Jorgensen <maj at stats.waikato.ac.nz> writes:
> 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?
Well, there's as.vector(rbind(x,z)) at least... I don't think things
get more elegant than that.
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
    
    
More information about the R-help
mailing list