# [R] generating a sequence

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Dec 21 13:59:31 CET 1999

```> From: "KAREN KOTSCHY" <karen at gecko.biol.wits.ac.za>
> To: r-help at stat.math.ethz.ch
> Date: Tue, 21 Dec 1999 14:20:55 GMT+2
> Subject: [R] generating a sequence
>
> Hi everyone
>
> I'm trying to generate a vector of the form
> a <- c(1,2,3,4,1,2,3,1,2,1) where n = 5
> in a general way, where n can be any positive integer.
>
> I've run out of ideas. Does anyone have any suggestions?

I am a bit puzzled here. Why is that n=5 not n=4? Anyway, try

A <- matrix(1, n-1, n-1)
rA <- row(A)
rA[rA + col(A) <= n]

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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