Bug 15717 - hist.POSIX reports "some 'x' not counted" with breaks="months"
Summary: hist.POSIX reports "some 'x' not counted" with breaks="months"
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 3.0.0
Hardware: x86_64/x64/amd64 (64-bit) Windows 32-bit
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-03-17 17:35 UTC by Andreas Borg
Modified: 2014-03-19 10:30 UTC (History)
0 users

See Also:


Attachments
Sample data (11.25 KB, text/comma-separated-values)
2014-03-17 17:35 UTC, Andreas Borg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Borg 2014-03-17 17:35:16 UTC
Created attachment 1581 [details]
Sample data

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:


> summary(timestamps)
                 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)
Comment 1 Brian Ripley 2014-03-19 10:30:19 UTC
This is not fully reproducible.  I guess

timestamps <- read.csv('sample-timestamps.csv', colClasses="POSIXct")[[1]]
hist(timestamps, breaks = "months")

was meant.

The rules have been changed slightly for R 3.1.0.