Method for hist applied to date or date-time objects.
Usage
## S3 method for class 'POSIXt'
hist(x, breaks, ...,
xlab = deparse(substitute(x)),
plot = TRUE, freq = FALSE,
start.on.monday = TRUE, format, right = TRUE)
## S3 method for class 'Date'
hist(x, breaks, ...,
xlab = deparse(substitute(x)),
plot = TRUE, freq = FALSE,
start.on.monday = TRUE, format, right = TRUE)
Arguments
x
an object inheriting from class "POSIXt" or "Date".
breaks
a vector of cut points or number giving the number of
intervals which x is to be cut into or an
interval specification, one of "days", "weeks",
"months", "quarters" or "years",
plus "secs", "mins", "hours" for
date-time objects.
...
graphical parameters, or arguments to
hist.default such as include.lowest,
right and labels.
xlab
a character string giving the label for the x axis, if plotted.
plot
logical. If TRUE (default), a histogram is
plotted, otherwise a list of breaks and counts is returned.
freq
logical; if TRUE, the
histogram graphic is a representation of frequencies, i.e,
the counts component of the result; if FALSE,
relative frequencies (probabilities) are plotted.
start.on.monday
logical. If breaks = "weeks", should the
week start on Mondays or Sundays?
format
for the x-axis labels. See strptime.
right
logical; if TRUE, the histogram cells are
right-closed (left open) intervals.
Details
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.
Value
An object of class "histogram": see hist.
See Also
seq.POSIXt, axis.POSIXct, hist
Examples
hist(.leap.seconds, "years", freq = TRUE)
hist(.leap.seconds,
seq(ISOdate(1970, 1, 1), ISOdate(2020, 1, 1), "5 years"))
## 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")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(graphics)
> png(filename="/home/ddbj/snapshot/RGM3/R_rel/result/graphics/hist.POSIXt.Rd_%03d_medium.png", width=480, height=480)
> ### Name: hist.POSIXt
> ### Title: Histogram of a Date or Date-Time Object
> ### Aliases: hist.POSIXt hist.Date
> ### Keywords: chron dplot hplot
>
> ### ** Examples
>
> hist(.leap.seconds, "years", freq = TRUE)
> hist(.leap.seconds,
+ seq(ISOdate(1970, 1, 1), ISOdate(2020, 1, 1), "5 years"))
>
> ## 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")
>
>
>
>
>
> dev.off()
null device
1
>