mappingEU {mapping} | R Documentation |
Static maps for Europe
Description
Function to produce static maps for European statistical unit.
Usage
mappingEU(data, var = NULL, colID = NULL,
type = c("static", "interactive"),
typeStatic = c("tmap", "choro.cart", "typo", "bar"),
unit = c("nuts0", "nuts1", "nuts2", "nuts3", "urau"),
year = c("2021","2016", "2013", "2010", "2006", "2003"),
matchWith = c("nuts", "id", "iso2", "iso3", "country_code"),
scale = c("20", "60"), dir = NULL, show_eu = TRUE,
add_text = NULL, subset = NULL, facets = NULL,
aggregation_fun = sum, aggregation_unit = NULL,
options = mapping.options())
Arguments
data |
a data.frame object with variables to display or a | ||||||||||
var |
character value(s) or columns number(s) indicating the variable to plot | ||||||||||
colID |
character value or columns number indicating the column with unit names | ||||||||||
type |
if generates static or interactive map | ||||||||||
typeStatic |
type of static map | ||||||||||
unit |
the type of European statistical unit to check | ||||||||||
year |
year of the unit | ||||||||||
matchWith |
the type of id to check:
| ||||||||||
scale |
the scale of a map | ||||||||||
dir |
local directory in which shape files are stored | ||||||||||
show_eu |
logical value set to TRUE indicating if the map entire map is drawn or only the coordinates linked to the input data | ||||||||||
add_text |
character name indicating the column with text labels | ||||||||||
subset |
a formula indicating the condition to subset the data. See the details | ||||||||||
facets |
variable(s) name to split the data | ||||||||||
aggregation_fun |
function to use when data are aggregated | ||||||||||
aggregation_unit |
variable name by which the unit are aggregated | ||||||||||
options |
a list with options using |
Details
If data
is a object of class "EU" generated using the EU
function, the arguments unit
, year
, and matchWith
are ignored, because the object already contains the coordinates.
The aggregation_unit
provides an aggregation for a user specified variable in data
, or for larger statistical unit, automatically provided when the function link the data
with the coordinates. For example, if data are of type nut2
, we will have variables for larger aggregate unit, that is nuts1
and nuts0
variables. Look at EU
for more details.
subset
provide an expression to subsetting the data
using a formula, with the logical operators. For example data can be subsetting as follows: ~I("Variable 1" == "condition 1" & "Variable 2" != "condition 2")
or for example, ~I("Variable 1" > "condition 1" | "Variable 2" != "condition 2")
.
Value
Returns a map. For tmap
type, the function also returns a tmap
object.
References
Giraud, T. and Lambert, N. (2016). cartography: Create and Integrate Maps in your R Workflow. JOSS, 1(4). doi: 10.21105/joss.00054.
Pebesma, E., 2018. Simple Features for R: Standardized Support for Spatial Vector Data. The R Journal 10 (1), 439-446, https://doi.org/10.32614/RJ-2018-009
Tennekes M (2018). “tmap: Thematic Maps in R.” _Journalstatisticaltical Software_, *84*(6), 1-39. doi: 10.18637/jss.v084.i06 (URL: https://doi.org/10.18637/jss.v084.i06).
See Also
mappingWR
,mappingIT
,mappingUS
,mappingDE
,mappingUK
Examples
data("popEU")
popEU <- popEU
euNuts2 <- EU(data = popEU, colID = "GEO",unit = "nuts2",matchWith = "id")
###############
# Statics #
###############
mappingEU(data = euNuts2, var = "total")
mappingEU(data = euNuts2, var = c("male","female"))
mappingEU(data = euNuts2, var = "total", subset = ~I(nuts0_id == "IT"))
mappingEU(data = euNuts2, var = "total",
subset = ~I(nuts0_id == "ES"), facets = "nuts2")
mappingEU(data = euNuts2, var = "total", typeStatic = "choro.cart")
mappingEU(data = euNuts2, var = "total", aggregation_unit = "nuts0", aggregation_fun = sum)
mappingEU(data = euNuts2, var = c("male","female"),
aggregation_unit = "nuts0", aggregation_fun = sum)
### Europe
eu1 <- loadCoordEU()
mappingEU(data = eu1)
###############
# Interactive #
###############
mappingEU(data = euNuts2, var = "total", type = "interactive")
mappingEU(data = euNuts2, var = c("male","female"), type = "interactive")
mappingEU(data = euNuts2, type = "interactive",
var = "total", subset = ~I(nuts0_id == "IT"))
mappingEU(data = euNuts2, var = "total", type = "interactive",
subset = ~I(nuts0_id == "ES"))
mappingEU(data = euNuts2, var = "total", type = "interactive")
mappingEU(data = euNuts2, var = "total", type = "interactive",
aggregation_unit = "nuts0",
aggregation_fun = sum)
mappingEU(data = euNuts2, var = c("male","female"), type = "interactive",
aggregation_unit = "nuts0", aggregation_fun = sum)