[R] generating a sequence
Wolfgang Koller
koller2 at fgr.wu-wien.ac.at
Tue Dec 21 15:08:25 CET 1999
You could also try the recursive way (surely slower for big n):
> recseq <- function(n) if (n==1) 1 else c(1:n,recseq(n-1))
> recseq(5)
[1] 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
> 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?
Wolfgang Koller
----------------------------------------------------------
Wolfgang Koller, koller2 at fgr.wu-wien.ac.at
Forschungsinstitut fuer Europafragen
Wirtschaftsuniversitaet Wien
Althanstrasse 39-45, 1090 Wien, Austria
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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