[R] seq()

Berwin A Turlach berwin at maths.uwa.edu.au
Wed Jan 21 18:41:30 CET 2009


G'day Felipe,

On Wed, 21 Jan 2009 09:29:03 -0800 (PST)
Felipe Carrillo <mazatlanmexico at yahoo.com> wrote:

> Could someone help me with the seq function? I have a range of values
> starting from 1 to 52 but I want seq to start at 27 by=2, but when it
> reaches 51 start with with number 1 to 25. is this possible. I can do
> the basics of seq() but I can't figure how to do this one. This is
> how I want my sequence to look like: 27 29 31 33 35 37 ............51
> 1 3 5 7 9 11 13 ...........25

Are you after something like:

R> c(seq(27,51,by=2), seq(1,25,by=2))
 [1] 27 29 31 33 35 37 39 41 43 45 47 49 51  1  3  5  7  9 11 13 15 17 19 21 23
[26] 25

or

R> seq(1,52,by=2)[c(14:26,1:13)]
 [1] 27 29 31 33 35 37 39 41 43 45 47 49 51  1  3  5  7  9 11 13 15 17 19 21 23
[26] 25

??

HTH.

Cheers,

	Berwin

=========================== Full address =============================
Berwin A Turlach                            Tel.: +65 6515 4416 (secr)
Dept of Statistics and Applied Probability        +65 6515 6650 (self)
Faculty of Science                          FAX : +65 6872 3919       
National University of Singapore
6 Science Drive 2, Blk S16, Level 7          e-mail: statba at nus.edu.sg
Singapore 117546                    http://www.stat.nus.edu.sg/~statba




More information about the R-help mailing list