Skip to content
Prev 26978 / 63434 Next

Wrong length of POSIXt vectors (PR#10507)

On 12/11/2007 6:20 AM, simecek at gmail.com wrote:
tv is a list of length 9.  The answer is right, your expectation is wrong.
See this in ?POSIXt:

Class '"POSIXlt"' is a named list of vectors...

You could define your own length measurement as

length.POSIXlt <- function(x) length(x$sec)

and you'll get the answer you expect, but be aware that length.XXX 
methods are quite rare, and you may surprise some of your users.

Duncan Murdoch