cskiadas at gmail.com
Sat Dec 8 15:52:34 CET 2007
On Dec 8, 2007, at 1:02 AM, Joe W. Byers wrote:
> In a post on R-devel, Prof Ripley add the following comment
> | > BTW, 1:dim(names) is dangerous: it could be 1:0. That was the
> | > motivation for seq_len.
> I use the dim(names) and dim(x) along with length(x) with
> levels of frustration depending on the object which I am trying to get
> the dimensions. I found the reference to seq_len interesting since it
> is a function that I have never seen (probably just missed it reading
> the docs).
> I was hoping someone could expand on the benefits of seq_len.
I think that example says it all. But in simpler form, suppose x is a
vector, and you want to produce a regular sequence of integers of the
same length. What should happen i the vector x has length 0? Here's
the output of the two commands.
 1 0
Other than treating the edge case correctly, the only other advantage
of seq_len, that I am aware of, is that it is faster. Not sure how
often that ends up mattering though.
> Happy Holidays
Department of Mathematics and Computer Science
More information about the R-help