From bill at insightful.com  Thu Jul 26 19:45:28 2007
From: bill at insightful.com (bill at insightful.com)
Date: Thu, 26 Jul 2007 19:45:28 +0200 (CEST)
Subject: [Rd] sequence(c(2, 0, 3)) produces surprising results,
	would like output length to be sum(input) (PR#9811)
Message-ID: <20070726174528.0B771667EA@slim.kubism.ku.dk>

Full_Name: Bill Dunlap
Version: 2.5.0
OS: Linux
Submission from: (NULL) (70.98.76.47)


sequence(nvec) is documented to return
the concatenation of seq(nvec[i]), for
i in seq(along=nvec).  This produces inconvenient
(for me) results for 0 inputs.
    > sequence(c(2,0,3)) # would like 1 2 1 2 3, ignore 0
    [1] 1 2 1 0 1 2 3
Would changing sequence(nvec) to use seq_len(nvec[i])
instead of the current 1:nvec[i] break much existing code?

On the other hand, almost no one seems to use sequence()
and it might make more sense to allow seq_len() and seq()
to accept a vector for length.out and they would return a
vector of length sum(length.out),
    c(seq_len(length.out[1]), seq_len(length.out[2]), ...)



[Rd] sequence(c(2, 0, 3)) produces surprising results, would like output length to be sum(input) (PR#9811)
bill at insightful.com