how to bind the same vector multiple times using R?

Posted by hendrik on Stack Overflow See other posts from Stack Overflow or by hendrik
Published on 2012-12-03T23:02:54Z Indexed on 2012/12/03 23:03 UTC
Read the original article Hit count: 182

Filed under:

question: how can i bind the same vector, lets say o=c(1,2,3,4) mutiple times to get a matrix like

o=array(c(1,2,3,4,1,2,3,4,1,2,3,4), dim(c(4,3))
  o


          [,1] [,2] [,3]
    [1,]    1    1    1
    [2,]    2    2    2
    [3,]    3    3    3
    [4,]    4    4    4

in a nicer way then: o=cbind(o,o,o) and maybe more generalized (dublicate()?? I need this to specifiy colors for elements in textplot()

thx a lot

© Stack Overflow or respective owner

Related posts about r