[R] alternative to rep

Dirk Eddelbuettel edd at debian.org
Wed Nov 13 23:50:19 CET 2002


> given: x<-c(2,5,4)
> If I "expand" x three times, then I will get 2,2,2,5,5,5,4,4,4.  In other 
> words, I want to keep the original ordering (2,5,4) but duplicate each of 
> the original entries three times.

> rep(c(2,5,4),rep(3,3))
[1] 2 2 2 5 5 5 4 4 4

Dirk

-- 
According to the latest figures, 43% of all signatures are totally worthless.   
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list