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

From: Herve Pages <hpages_at_fhcrc.org>
Date: Thu, 12 Jul 2007 18:25:59 -0700


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.



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 13 Jul 2007 - 01:29:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 13 Jul 2007 - 01:36:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.