build_pmap | R Documentation |
This function builds a choropleth map that visualises estimates and errors simultaneously through pixelation and sampling.
build_pmap(
data = NULL,
distribution = NULL,
pixelGeo,
id,
border = NULL,
palette = "Blues",
q = NULL,
limits = NULL
)
data |
A data frame. |
distribution |
Name of the distribution that the pixel assignments will
be drawn from. It must be one of |
pixelGeo |
An object from |
id |
Name of the common column shared by the objects passed to
|
border |
An sf or sp object. Or, one of |
palette |
Name of colour palette. It must be one of |
q |
A data frame of quantiles which define the distribution for each
estimate. Each row is an estimate, and each column is a quantile. See
examples for an example of |
limits |
Limits for the legend. Default is NULL, which takes the limits to be the range of the data. |
animate
## Not run:
# This code will produce a pixelated map when run in R
# It is not run here.
data(us_geo)
ca_geo <- subset(us_geo, us_geo@data$STATE == "06")
pix <- pixelate(geoData = ca_geo, pixelSize = 70, id = "GEO_ID")
data(us_data)
us_data$GEO.id2 <- as.numeric(us_data$GEO.id2)
ca_data <- subset(us_data, us_data$GEO.id2 > 6000 & us_data$GEO.id2 < 7000)
ca_data <- read.uv(data = ca_data, estimate = "pov_rate", error = "pov_moe")
row.names(ca_data) <- seq(1, nrow(ca_data), 1)
# uniform distribution
m <- build_pmap(data = ca_data, distribution = "uniform", pixelGeo = pix, id = "GEO_ID")
view(m)
# normal distribution
ca_data$se <- ca_data$pov_moe / 1.645
ca_data <- read.uv(data = ca_data, estimate = "pov_rate", error = "se")
m <- build_pmap(data = ca_data, distribution = "normal", pixelGeo = pix, id = "GEO_ID")
view(m)
# experiment with discrete distribution
# exponential - example for q argument
ca_data.q <- with(ca_data, data.frame(p0.05 = qexp(0.05, 1/pov_rate),
p0.25 = qexp(0.25, 1/pov_rate), p0.5 = qexp(0.5, 1/pov_rate),
p0.75 = qexp(0.75, 1/pov_rate), p0.95 = qexp(0.95, 1/pov_rate)))
m <- build_pmap(data = ca_data, distribution = "discrete", pixelGeo = pix,
id = "GEO_ID", q = ca_data.q)
view(m)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.