Benilton Carvalho writes: > I'm no expert on this, but my understanding is that the choice was > to stick to the definition. > > The help file for length() [1] says: > > "For vectors (including lists) and factors the length is the number > of elements." > > The help file for POSIXlt [2] (for example) says: > > "Class ?"POSIXlt"? is a named list of vectors representing (...)" > > and then lists the 9 elements (sec / min / hour / mday / mon / year > / wday / yday / isdst). > > So, by [1] length of POSIXlt objects is 9, because it "is a named > list of vectors representing (...)".
Thanks, all. Yes, I'd already read both, and it's obviously true that a length() of 9 is correct (as I said up-front). The difficulty is that some functions -- importantly including "[" -- already have methods which make POSIXlt behave like a vector. The documentation for POSIXlt just says it's a list of 9 elements: it mentions methods for addition etc, but AFAICT it doesn't say that subsetting won't behave is "["'s help says for a list-like object. In the end, "[" sees a different length to "[[" and "$" here, so a length.POSIXlt() just shuffles the issue around. Anyhow, I somehow missed there have been other PRs on this, including discussion on r-devel of "[" and logical vs physical length() under PR#10507. I'm sorry for being repetitive. Mark <>< ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel