tidyst_as_kde | R Documentation |
Tidy and geospatial versions of quasi kernel density estimates for 1- and 2-dimensional gridded data.
tidy_as_kde(data, density, ...)
st_as_kde(x, attrib=1, density, ...)
data |
data frame/tibble, where first d columns are evaluation points of an estimation grid, and last column is estimate value |
x |
sf object, where |
attrib |
name or position of estimate variable. Default is 1. |
density |
flag to compute bona fide density. Default is TRUE. |
... |
other parameters |
If density=TRUE
then all the estimate values are non-negative. If density=FALSE
then the estimate values can be positive or negative.
The input gridded data should be a tidy form of a complete Cartesian product that forms a regular rectangular grid with no missing values or grid points/polygons. The input is converted to a quasi density estimate so that it can be subsequently treated like an output from tidy_kde
or st_kde
.
## tidy quasi density estimate
library(ggplot2)
data(faithfuld, package="ggplot2")
t1 <- tidy_as_kde(faithfuld)
## probabilistic density contour levels
ggplot(t1, aes(x=eruptions, y=waiting)) +
geom_contour_filled_ks(colour=1, aes(fill=after_stat(contperc)))
## non-probabilistic contour levels in ggplot2::geom_contour_filled
ggplot(faithfuld, aes(x=eruptions, y=waiting, z=density)) +
geom_contour_filled(bins=4) +
colorspace::scale_fill_discrete_sequential(palette="Heat")
## geospatial quasi density estimate
## see example in ? st_intergrid
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.