stat_na | R Documentation |
Useful for indicating or masking missing data. This stat subsets data where
one variable is NA
.
stat_na(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
...,
show.legend = NA,
inherit.aes = TRUE
)
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 for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
stat_na
understands the following aesthetics (required aesthetics are in bold)
x
y
na
width
height
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()
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.