Prof Brian Ripley (ripley@stats.ox.ac.uk)
Tue, 21 Dec 1999 12:59:31 +0000 (GMT)
> From: "KAREN KOTSCHY" <karen@gecko.biol.wits.ac.za>
> To: r-help@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@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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.0b3 on Tue 04 Jan 2000 - 13:34:03 EST