| stat_na {metR} | R Documentation |
Filter only NA values.
Description
Useful for indicating or masking missing data. This stat subsets data where
one variable is NA.
Usage
stat_na(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
...,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data, either as a
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Aesthetics
stat_na understands the following aesthetics (required aesthetics are in bold)
-
x
-
y
-
na
-
width -
height
See Also
stat_subset for a more general way of filtering data.
Other ggplot2 helpers:
MakeBreaks(),
WrapCircular(),
geom_arrow(),
geom_contour2(),
geom_contour_fill(),
geom_label_contour(),
geom_relief(),
geom_streamline(),
guide_colourstrip(),
map_labels,
reverselog_trans(),
scale_divergent,
scale_longitude,
stat_subset()
Examples
library(ggplot2)
library(data.table)
surface <- reshape2::melt(volcano)
surface <- within(surface, value[Var1 %between% c(20, 30) & Var2 %between% c(20, 30)] <- NA)
surface[sample(1:nrow(surface), 100, replace = FALSE), 3] <- NA
ggplot(surface, aes(Var1, Var2, z = value)) +
geom_contour_fill(na.fill = TRUE) +
stat_na(aes(na = value), geom = "tile")