View source: R/map_indicators.R
map_indicators | R Documentation |
Function map_indicators
visualizes estimates from a
SAEforestObject
on a specified map. The function can be seen as a modified
wrapper of map_plot
from the package emdi.
map_indicators( object, indicator = "all", MSE = FALSE, CV = FALSE, map_obj = NULL, map_dom_id = NULL, map_tab = NULL, color = c("white", "darkgreen"), scale_points = NULL, guide = "colourbar", return_data = FALSE, return_plot = FALSE, gg_theme = theme_minimal() )
object |
An object of class |
indicator |
Optional character vector specifying indicators to be mapped: (i)
all calculated indicators ("all"); (ii) default indicators name: "Mean",
"Quant10", "Quant25", "Median", "Quant75", "Quant90", "Gini", "Hcr", "Pgap", "Qsr"
or the function name/s of "custom_indicator/s"; (iii) a vector of names of indicators.
If the |
MSE |
Logical. If |
CV |
Logical. If |
map_obj |
An |
map_dom_id |
Character string containing the name of a variable in
|
map_tab |
A |
color |
A |
scale_points |
A structure defining the lowest, the mid and the highest value of the colorscale. If a numeric vector of length two is given, this scale will be used for every plot. Alternatively, a list defining colors for each plot separately may be given. |
guide |
Character passed to |
return_data |
If set to |
return_plot |
If set to |
gg_theme |
Specify a predefined theme from ggplot2. Defaults to |
Creates required plots and if selected, a fortified data.frame and a list of plots.
SAEforest
, readShapePoly
,
SpatialPolygonsDataFrame
, ggplot
.
# Loading data data("eusilcA_pop") data("eusilcA_smp") data("shape_Aut") income <- eusilcA_smp$eqIncome X_covar <- eusilcA_smp[, -c(1, 16, 17, 18)] # Example 1: # Calculating point estimates and discussing basic generic functions model1 <- SAEforest_model(Y = income, X = X_covar, dName = "district", smp_data = eusilcA_smp, pop_data = eusilcA_pop, num.trees = 50) # Create map plot for mean indicator - point and MSE estimates but no CV map_indicators(object = model1, MSE = FALSE, CV = FALSE, map_obj = shape_Aut, indicator = c("Mean"), map_dom_id = "PB") # Create a suitable mapping table to use numerical identifiers of the shape # file # First find the right order dom_ord <- match(shape_Aut@data$PB, model1$Indicators$district) # Create the mapping table based on the order obtained above map_tab <- data.frame(pop_data_id = model1$Indicators$district[dom_ord], shape_id = shape_Aut@data$BKZ) # Create map plot for mean indicator - using the numerical domain # identifiers of the shape file. Additionally save the figure in as a list element. map_obj <- map_indicators(object = model1, MSE = FALSE, CV = FALSE, map_obj = shape_Aut, indicator = c("Mean"), map_dom_id = "BKZ", map_tab = map_tab, return_plot = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.