From hpages at fhcrc.org  Fri Jul 13 03:25:59 2007
From: hpages at fhcrc.org (Herve Pages)
Date: Thu, 12 Jul 2007 18:25:59 -0700
Subject: [Rd] seq_along() doesn't use _my_ length
Message-ID: <4696D4A7.404@fhcrc.org>

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.



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