Stephen G Matthews
2014-Apr-25 19:00 UTC
[R] error from hist() with POSIXt 00 seconds for breaks of secs, mins, hours, or day
Hello, When using hist() with a POSIXt date that has 00 seconds an error is produced. For example> hist(as.POSIXlt("2010-07-01 00:00:00"), breaks="mins")Error in seq_len(1L + max(which(breaks < maxx))) : argument must be coercible to non-negative integer In addition: Warning message: In max(which(breaks < maxx)) : no non-missing arguments to max; returning -Inf> hist(as.POSIXlt("2010-07-01 10:10:00"), breaks="mins")Error in seq_len(1L + max(which(breaks < maxx))) : argument must be coercible to non-negative integer In addition: Warning message: In max(which(breaks < maxx)) : no non-missing arguments to max; returning -Inf When adding one second, it completes successfully.> hist(as.POSIXlt("2010-07-01 00:00:01"), breaks="mins")> hist(as.POSIXlt("2010-07-01 10:10:01"), breaks="mins")The error is produced when breaks is either secs, mins, hours, or day, but does not occur with year, month or week. I realise a histogram of one element is not useful, however, the errors produced seem inconsistent. Is this expected behaviour? This maybe useful:> sessionInfo()R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 [3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C [5] LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_3.0.1 Best wishes Steve [[alternative HTML version deleted]]