Re: [Rd] RFC: Redefining length(<POSIXlt>) ?

From: Gregor Gorjanc <gregor.gorjanc_at_bfro.uni-lj.si>
Date: Mon 24 Jul 2006 - 12:48:14 GMT

Hi,

Martin Maechler <maechler <at> stat.math.ethz.ch> writes:

>
> So I did open a new subject and move the discussion to R-devel
> now.
>
> >>>>> "MM" == Martin Maechler <maechler <at> stat.math.ethz.ch>

> >>>>> on Mon, 24 Jul 2006 11:46:05 +0200 writes:
>
> >>>>> "Gabor" == Gabor Grothendieck <ggrothendieck <at> gmail.com>
> >>>>> on Sun, 23 Jul 2006 09:02:35 -0400 writes:
>
> Gabor> Looking at the diff.POSIXt code we see the problem is
> Gabor> that it takes the length of the input using length
> Gabor> which is wrong since in the case of POSIXlt the
> Gabor> length is always 9 (or maybe length should be defined
> Gabor> differently for POSIXlt?).
>
> MM> Though I agree with Spencer that a user may expect
> MM> length() to behave differently, but I don't think this
> MM> would be a good idea. Yes, length() is generic, but its
> MM> help() emphasizes that for lists, length() should be the
> MM> number of list elements. Of course anyone one *can*
> MM> define length() methods that behave differently for
> MM> his/her classes, but then one would also want to make
> MM> sure that e.g. x[length(x)] or 'x[length(x)] <- value'
> MM> works and -- in a case of simple S3 class built on a
> MM> list, would work differently than if x was a the simple list.

I think that having generic for POSIXlt would be more natural than default length, which is (as stated by Gabor) always 9. When I see a date or time with all additions I always think of it as one "element". So it would be naturaly that length() would return number of dates/times in POSIXlt object.

Gregor



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Jul 24 22:56:35 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 24 Jul 2006 - 14:30:27 GMT.

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