On 27 Jul 2007, at 08:07, [EMAIL PROTECTED] wrote: > This is as doumented, and I think you could say the same thing of > seq(). > BTW, sequence() allows negative inputs, and I don't think you want > sum(input) in that case. > > I've never seen the point of sequence(), but it has been around in > R for a > long time. It is used in packages eRm, extRemes, hydrosanity, > klaR, seas. > Who knows what people have in private code, so I don't see any > compelling > case to change it. If people want a different version, it would > only take > a minute to write (see below). > > We could make seq_len take a vector argument, but as you point out > in a > followup that makes it slower in the common case. It also changes its > meaning if a length > 1 vector is supplied, and would speed matter > in the > long-vector case? What does > > sequence0 <- function (nvec) > { > s <- integer(0) > for (i in nvec) s <- c(s, seq_len(i)) > s > } > > not do that is more than a very rare need? >
My 2 cents: Defining mySequence <- function(x){unlist(sapply(x,function(i){seq_len (i)}))} is much faster. Neither sequence0() nor mySequence() accepts vectors with any element <0 although as Brian Ripley points out, sequence() itself does (which I think is undesirable). Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel