s-news
[Top] [All Lists]

abusing seq

To: <s-news@wubios.wustl.edu>
Subject: abusing seq
From: "Joseph S. Verducci" <jsv@stat.ohio-state.edu>
Date: Sun, 29 Jul 2001 13:01:36 -0400 (EDT)
Dear Sers:

   In a blatant abuse of an innocent and well-respected function,
I tried the following command:

   seq(from=2,by=c(1,2),length=20)

which resulted in

 [1]  2  4  4  8  6 12  8 16 10 20 12 24 14 28 16 32 18 36 20 40

Even though I don't remember seeing this sequence in an IQ test,
the following rule seems to work {with an abuse of Splus notation}:
  a[odd] = seq(from=2,by=2)
  a[even] = seq(from=4,by=4)


Similarly,

  seq(from=1,by=c(2,3),length=20)

results in

 [1]  1  4  5 10  9 16 13 22 17 28 21 34 25 40 29 46 33 52 37 58

with
  a[odd] = seq(from=1,by=4)
  a[even] = seq(from=4,by=6)

Can anyone explain the general behavior of "seq" when "by" is given a
vector argument?

Yours guiltily,
    JV





<Prev in Thread] Current Thread [Next in Thread>