hist.POSIXt {graphics} | R Documentation |
Methods for hist
applied to date (class "Date"
)
or date-time (class "POSIXt"
) objects.
## S3 method for class 'POSIXt'
hist(x, breaks, ...,
xlab = deparse1(substitute(x)),
plot = TRUE, freq = FALSE,
start.on.monday = TRUE, format, right = TRUE)
## S3 method for class 'Date'
hist(x, breaks, ...,
xlab = deparse1(substitute(x)),
plot = TRUE, freq = FALSE,
start.on.monday = TRUE, format, right = TRUE)
x |
|
breaks |
a vector of cut points or number giving the number of
intervals which |
... |
graphical parameters, or arguments to
|
xlab |
a character string giving the label for the x axis, if plotted. |
plot |
logical. If |
freq |
logical; if |
start.on.monday |
logical. If |
format |
for the x-axis labels. See |
right |
logical; if |
Note that unlike the default method, breaks
is a required argument.
Using breaks = "quarters"
will create intervals of 3 calendar
months, with the intervals beginning on January 1, April 1,
July 1 or October 1, based upon min(x)
as appropriate.
With the default right = TRUE
, breaks will be set
on the last day of the previous period when breaks
is
"months"
, "quarters"
or "years"
. Use
right = FALSE
to set them to the first day of the
interval shown in each bar.
An object of class "histogram"
: see hist
.
seq.POSIXt
, axis.POSIXct
, hist
hist(.leap.seconds, "years", freq = TRUE)
brks <- seq(ISOdate(1970, 1, 1), ISOdate(2030, 1, 1), "5 years")
hist(.leap.seconds, brks)
rug(.leap.seconds, lwd=2)
## show that 'include.lowest' "works"
stopifnot(identical(c(2L, rep(1L,11)),
hist(brks, brks, plot=FALSE, include.lowest=TRUE )$counts))
tools::assertError(verbose=TRUE, ##--> 'breaks' do not span range of 'x'
hist(brks, brks, plot=FALSE, include.lowest=FALSE))
## The default fuzz in hist.default() "kills" this, with a "wrong" message:
try ( hist(brks[-13] + 1, brks, include.lowest = FALSE) )
## and decreasing 'fuzz' solves the issue:
hb <- hist(brks[-13] + 1, brks, include.lowest = FALSE, fuzz = 1e-10)
stopifnot(hb$counts == 1)
## 100 random dates in a 10-week period
random.dates <- as.Date("2001/1/1") + 70*stats::runif(100)
hist(random.dates, "weeks", format = "%d %b")