[Rd] Wrong length of POSIXt vectors (PR#10507)

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Wed Dec 12 15:39:53 CET 2007


simecek at gmail.com wrote:
> Full_Name: Petr Simecek
> Version: 2.5.1, 2.6.1
> OS: Windows XP
> Submission from: (NULL) (195.113.231.2)
>
>
> Several times I have experienced that a length of a POSIXt vector has not been
> computed right.
>
> Example:
>
> tv<-structure(list(sec = c(50, 0, 55, 12, 2, 0, 37, NA, 17, 3, 31
> ), min = c(1L, 10L, 11L, 15L, 16L, 18L, 18L, NA, 20L, 22L, 22L
> ), hour = c(12L, 12L, 12L, 12L, 12L, 12L, 12L, NA, 12L, 12L, 
> 12L), mday = c(13L, 13L, 13L, 13L, 13L, 13L, 13L, NA, 13L, 13L, 
> 13L), mon = c(5L, 5L, 5L, 5L, 5L, 5L, 5L, NA, 5L, 5L, 5L), year = c(105L, 
> 105L, 105L, 105L, 105L, 105L, 105L, NA, 105L, 105L, 105L), wday = c(1L, 
> 1L, 1L, 1L, 1L, 1L, 1L, NA, 1L, 1L, 1L), yday = c(163L, 163L, 
> 163L, 163L, 163L, 163L, 163L, NA, 163L, 163L, 163L), isdst = c(1L, 
> 1L, 1L, 1L, 1L, 1L, 1L, -1L, 1L, 1L, 1L)), .Names = c("sec", 
> "min", "hour", "mday", "mon", "year", "wday", "yday", "isdst"
> ), class = c("POSIXt", "POSIXlt"))
>
> print(tv)
> # print 11 time points (right)
>
> length(tv)
> # returns 9 (wrong)
>
> I have tried that on several computers with/without switching to English
> locales, i.e. Sys.setlocale("LC_TIME", "en"). I have searched a help pages but I
> cannot imagine how that could be OK.
>
>   
Given the way you define it, you should be able to imagine it!

It's a list of length 9:  sec, min, hour,..., isdst.


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-devel mailing list