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 <[EMAIL PROTECTED]>
Date: Friday, September 29, 2006 11:23 pm
Subject: How to repeat vectors ?
To: [email protected]

> 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
>

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to