[R] How to repeat vectors ?
    Tong Wang 
    wangtong at usc.edu
       
    Sat Sep 30 08:33:36 CEST 2006
    
    
  
I just figured out a way to do this: 
          rep.vec <- function(X,n)    return(t(array(rep(X,n),c(length(X),n))))
    
   Then,    apply(MyMatrix, 2, rep.vec,2)
Is there a better way ?  Is there an internal function to repeat a vector or matrix ?
Thanks a lot.
----- Original Message -----
From: Tong Wang <wangtong at usc.edu>
Date: Friday, September 29, 2006 11:23 pm
Subject: How to repeat vectors ?
To: r-help at stat.math.ethz.ch
> Hi,
>    If I have a matrix  , say       a11   a12
>                                                   a21  a22
>    Is there a routine to get:      a11  a12
>                                                     a11  a12
>                                                     a21   a22
>                                                     a21   a22
> 
>     Thanks a lot for any help.
> 
> best
>
    
    
More information about the R-help
mailing list