This function calculates the mean y-value for each x-value. Should be used
only when x
is discrete. The resulting mean can be mapped to any
aesthetic, specified with the output
parameter.
stat_meanByHour(
mapping = NULL,
data = NULL,
input = NULL,
output = "y",
geom = "bar",
position = "identity",
na.rm = TRUE,
show.legend = NA,
inherit.aes = TRUE,
...
)
Set of aesthetic mappings created by aes()
. If
specified and inherit.aes = TRUE
(the default), it is combined with
the default mapping at the top level of the plot. You must supply
mapping
if there is no plot mapping.
The data to be displayed in this layer. There are three options:
if NULL
, the default, the data is inherited from the plot data. A
data.frame
or other object, will override the plot data. A
function
will be called with a single argument, the plot data. The
return value must be a data.frame
, and will be used as the layer
data.
The value to find the mean of. If NULL
, the default
y
value will be used.
"AQIColors", "mv4Colors", "scaqmd", "y"
The geometic object to display the data
Position adjustment, either as a string, or the result of a call to a position adjustment function.
remove NA values from data
logical indicating whether this layer should be included in legends.
if FALSE
, overrides the default aesthetics, rather
than combining with them. This is most useful for helper functions that
define both data and the aesthetics and shouldn't inherit behaviour from
the default plot specificatino, eg borders()
.
additional arguments passed on to layer()
, such as
aesthetics.
if (FALSE) {
library(AirMonitorPlots)
ggplot_pm25Timeseries(
AirMonitor::NW_Megafires,
startdate = 20150820,
enddate = 20150831
) +
geom_point(shape = "square", alpha = 0.05) +
stat_meanByHour(geom = "line", color = "orange", size = 3)
ggplot_pm25Diurnal(
AirMonitor::Carmel_Valley,
startdate = 20160801,
enddate = 20160810
) +
geom_path(aes(group = day), color = "gray50") +
stat_meanByHour(geom = "line", size = 4)
}