[R] creating list of the from 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, . . ., n, n, n?

Steve Lianoglou mailinglist.honeypot at gmail.com
Fri Aug 14 16:53:24 CEST 2009


Hi,

On Aug 14, 2009, at 10:44 AM, John Sorkin wrote:

> Windows XP
> R 2.8.1
>
> Is there any way to make a list of the from
> 1,1,1,2,2,2,3,3,3,4,4,4, . . ., n,n,n?

Like so?

R> rep(1:10, each=3)
[1]  1  1  1  2  2  2  3  3  3  4  4  4  5  5  5  6  6  6  7  7  7  8   
8  8  9
[26]  9  9 10 10 10

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
   |  Memorial Sloan-Kettering Cancer Center
   |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




More information about the R-help mailing list