[Rd] seq_along() doesn't use _my_ length

Herve Pages hpages at fhcrc.org
Fri Jul 13 03:25:59 CEST 2007


Hi,

According to seq_along man page, 'seq_along(x)' is equivalent to
'seq_len(length(x))' but apparently not if 'x' is an S4 object with
a defined "length" method:

  > seq_along(letters[11:15])
  [1] 1 2 3 4 5

  > setClass("A", representation(titi="character"))
  [1] "A"

  > setMethod("length", "A", function(x) length(x at titi))
  [1] "length"

  > a <- new("A", titi=letters[11:15])

  > length(a)
  [1] 5

  > seq_along(a)
  [1] 1

Thanks!
H.



More information about the R-devel mailing list