Created attachment 1581 [details]
I am calculating histograms on time series in POSIXct format. I use 'breaks="months"' to get monthly totals. With my data, I get the following error:
> hist(timestamps, breaks="months")
Error in hist.default(unclass(x), unclass(breaks), plot = FALSE, warn.unused = FALSE, :
some 'x' not counted; maybe 'breaks' do not span range of 'x'
I checked with summary that the object is valid:
Min. 1st Qu. Median Mean
"2014-01-02 11:43:24" "2014-01-17 12:42:00" "2014-01-30 11:57:10" "2014-01-31 14:49:05"
3rd Qu. Max.
"2014-02-13 10:05:59" "2014-02-28 15:23:53"
As can be seen, the time series includes entries from January and February 2014.
Now, if I add a date in March, it works:
> hist(c(timestamps, as.POSIXct("2014-03-01")), breaks="months")
I do not see any reason why hist should complain about range and breaks when I define an interval for breaks.
The real data I use spans a couple of years, the sample data in the attachement is cut down to save space.
Use the following code to read the sample data:
dataTable <- read.table("sample-timestamps.csv", sep=";", quote="\"")
timestamps <- as.POSIXct(dataTable[,1])
I got this error in versions 3.0.0 and 3.0.3 (there is no option to choose 3.0.3 in the bug report form)
This is not fully reproducible. I guess
timestamps <- read.csv('sample-timestamps.csv', colClasses="POSIXct")[]
hist(timestamps, breaks = "months")
The rules have been changed slightly for R 3.1.0.