[R] numeric(0)

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Dec 29 18:54:36 CET 2004

(Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> writes:

> On 29-Dec-04 dax42 wrote:
> > for(j in 1:length(sequence)-1){

> You've fallen into a classic trap: 1:length(sequence)-1 does not
> mean what one might naturally expect.

It might be a good time to warn that 1:(length(sequence)-1) does not
always mean what you might naturally expect either.
seq(length=length(sequence)-1) is safer, and you may in addition want
to safeguard against the case length(sequence)==0.

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907

More information about the R-help mailing list