Re: [R] Alternating numbers in rep()

2008-01-24 Thread Greg Snow
[mailto:[EMAIL PROTECTED] On Behalf Of Greg Snow > Sent: Thursday, January 24, 2008 1:33 PM > To: David Afshartous; r-help@r-project.org > Subject: Re: [R] Alternating numbers in rep() > > Here are a couple of options (I'm sure there are plenty of > others) that replicate your

Re: [R] Alternating numbers in rep()

2008-01-24 Thread Greg Snow
[EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous > Sent: Thursday, January 24, 2008 1:03 PM > To: r-help@r-project.org > Subject: [R] Alternating numbers in rep() > > > All, > > I'm trying to obtain a one-liner to generate a certain

Re: [R] Alternating numbers in rep()

2008-01-24 Thread Gabor Csardi
On Thu, Jan 24, 2008 at 03:03:22PM -0500, David Afshartous wrote: > > All, > > I'm trying to obtain a one-liner to generate a certain sequence of > alternatign numbers. > > Consider: > > unlist(rep(list(c(1,2), c(3,4)), each = 6)) > [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 > > I'd l

Re: [R] Alternating numbers in rep()

2008-01-24 Thread Charles C. Berry
This ?? as.vector( outer(0:1, rep(seq(1,37,by=2), each=6), "+" ) ) On Thu, 24 Jan 2008, David Afshartous wrote: > > All, > > I'm trying to obtain a one-liner to generate a certain sequence of > alternatign numbers. > > Consider: >> unlist(rep(list(c(1,2), c(3,4)), each = 6)) > [1] 1 2 1 2

[R] Alternating numbers in rep()

2008-01-24 Thread David Afshartous
All, I'm trying to obtain a one-liner to generate a certain sequence of alternatign numbers. Consider: > unlist(rep(list(c(1,2), c(3,4)), each = 6)) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 I'd like the result to be as above but continue until 38. Of course, I could hardcode this g