Skip to content
Prev 131598 / 398502 Next

seq_len

On Dec 8, 2007, at 1:02 AM, Joe W. Byers wrote:

            
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.

x<-numeric(0)
 > y<-length(x)
 > y
[1] 0
 > 1:y
[1] 1 0
 > seq_len(y)
integer(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.
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College