Title: | Automatic Download, Linking, Manipulating Coordinates for Maps |
---|---|
Description: | Maps are an important tool to visualise variables distribution across different spatial objects. The mapping process requires to link the data with coordinates and then generate the correspondent map. This package provide coordinates, linking and mapping functions for an automatic, flexible and easy approach of external functions. The package provides an easy, flexible and automatic unit. Geographical coordinates are provided in the package and automatically linked with the input data to generate maps with internal provided functions or external functions. Provide an easy, flexible and automatic approach to potentially download updated coordinates, to link statistical units with coordinates and to aggregate variables based on the spatial hierarchy of units. The object returned from the package can be used for thematic maps with the build-in functions provided in mapping or with other packages already available. |
Authors: | Alessio Serafini [aut, cre], Giancarlo Ferrara [aut] |
Maintainer: | Alessio Serafini <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.4.1 |
Built: | 2025-02-10 05:49:28 UTC |
Source: | https://github.com/mappinguniverse/mapping |
Check the differences between the names (or codes) given in input and the names (or codes), of the corresponding selected Germany statistical unit.
checkNamesDE(id, unit = c("state", "district", "municipal", "municipality"), matchWith = c("name", "code", "code_full"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
checkNamesDE(id, unit = c("state", "district", "municipal", "municipality"), matchWith = c("name", "code", "code_full"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
id |
character vector with names or codes |
||||||
unit |
the type of European statistical unit to check |
||||||
matchWith |
the type of id to check:
|
||||||
return_logical |
a logical value indicating whether nomatched id are returned. |
||||||
print |
a logical value indicating whether print the nomatched names |
||||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
The function provides a check between id name or code in the dataset and the corresponding selected Germany statistical unit. unit
starts from the largest aggregate, "state", to the smallest, "municipality".
Returns a string vector with nomatched names or a boolean vector indicating whether or not the id matched.
Alessio Serafini
checkNamesEU
, checkNamesUS
, checkNamesWR
, checkNamesUK
data("popDE") ck <- checkNamesDE(popDE$code_state, unit = "state", matchWith = "code_full") str(ck)
data("popDE") ck <- checkNamesDE(popDE$code_state, unit = "state", matchWith = "code_full") str(ck)
Check the differences between the names (or codes) given in input and the names (or codes), as provided by Eurostat, of the corresponding selected European statistical unit.
checkNamesEU(id, 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"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
checkNamesEU(id, 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"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
id |
character vector with names or codes |
||||||||||
unit |
the type of European statistical unit to check |
||||||||||
year |
year of the analysis |
||||||||||
matchWith |
the type of id to check:
|
||||||||||
scale |
the scale of the map. |
||||||||||
return_logical |
a logical value indicating whether nomatched id are returned. |
||||||||||
print |
a logical value indicating whether print the nomatched names |
||||||||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
The function provides a check between id name in the dataset and the European statistical unit. unit
starts from the largest aggregate, "nuts0" (European country), to the smallest, "nuts3". Since unit can change over the years, the year of the data has to be provided.
The single unit can be coded in different ways, with names, id or iso standard.
Returns a string vector with nomatched names or a boolean vector indicating whether or not the id matched.
Alessio Serafini
checkNamesIT
, checkNamesUS
, checkNamesWR
data("popEU") data("popEUnuts2") # Chech only the country ck <- checkNamesEU(id = popEU$GEO, unit = "nuts0", matchWith = "id") ck1 <- checkNamesEU(id = popEU$GEO, unit = "nuts0", matchWith = "id", return_logical = TRUE, print = FALSE) popEU[ck1,] ck2 <- checkNamesEU(id = popEUnuts2$GEO, unit = "nuts2", matchWith = "id")
data("popEU") data("popEUnuts2") # Chech only the country ck <- checkNamesEU(id = popEU$GEO, unit = "nuts0", matchWith = "id") ck1 <- checkNamesEU(id = popEU$GEO, unit = "nuts0", matchWith = "id", return_logical = TRUE, print = FALSE) popEU[ck1,] ck2 <- checkNamesEU(id = popEUnuts2$GEO, unit = "nuts2", matchWith = "id")
Check the differences between the names (or codes) given in input and the corresponding names (or codes), as provided by ISTAT, of the selected Italian statistical unit.
checkNamesIT(id, unit = c("ripartizione", "regione", "provincia","comune"), year = c("2021","2020", "2019", "2018", "2017"), matchWith = c("name", "code", "number"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
checkNamesIT(id, unit = c("ripartizione", "regione", "provincia","comune"), year = c("2021","2020", "2019", "2018", "2017"), matchWith = c("name", "code", "number"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
id |
character vector with names or codes |
||||||
unit |
the type of Italian statistical unit to check |
||||||
year |
year of the analysis |
||||||
matchWith |
the type of id to check:
|
||||||
return_logical |
a logical value indicating whether nomatched id are returned |
||||||
print |
a logical value indicating whether print the nomatched names |
||||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
The function provides a check between id name or code in the dataset and the corresponding selected Italian statistical unit. unit
starts from the largest aggregate, "ripartizione", to the smallest, "comune". Since unit can change over the years, the year of the data has to be provided.
Returns a string vector with nomatched names or a boolean vector indicating whether or not the id matched.
Alessio Serafini
checkNamesEU
, checkNamesUS
, checkNamesWR
data("popIT") ck <- checkNamesIT(popIT$ID, unit = "provincia") str(ck) ck <- checkNamesIT(popIT$ID, unit = "provincia", return_logical = TRUE) str(ck)
data("popIT") ck <- checkNamesIT(popIT$ID, unit = "provincia") str(ck) ck <- checkNamesIT(popIT$ID, unit = "provincia", return_logical = TRUE) str(ck)
Check the differences between the names (or codes) given in input and the names (or codes) of the corresponding selected United Kingdom statistical unit.
checkNamesUK(id, unit = c("country", "county"), year = c("2020", "2019"), matchWith = c("name", "code"), scale = c("500", "20"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
checkNamesUK(id, unit = c("country", "county"), year = c("2020", "2019"), matchWith = c("name", "code"), scale = c("500", "20"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
id |
character vector with names or codes |
||||
unit |
the type of European statistical unit to check |
||||
year |
year of the analysis |
||||
matchWith |
the type of id to check:
|
||||
scale |
the scale of the map. |
||||
return_logical |
a logical value indicating whether nomatched id are returned. |
||||
print |
a logical value indicating whether print the nomatched names |
||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
The function provides a check between id name or code in the dataset and the corresponding selected United Kingdom statistical unit. unit
starts from the largest aggregate, "country", to the smallest, "county". Since unit can change over the years, the year of the data has to be provided.
Returns a string vector with nomatched names or a boolean vector indicating whether or not the id matched.
Alessio Serafini
checkNamesEU
, checkNamesUS
, checkNamesWR
, checkNamesDE
data("popUK") ck <- checkNamesUK(popUK$name, unit = "country") str(ck)
data("popUK") ck <- checkNamesUK(popUK$name, unit = "country") str(ck)
Check the differences between the names given in input and the names, as provided by United States Census of Bureau, of the corresponding USA statistical unit.
checkNamesUS(id, unit = c("country", "region", "division", "state", "county", "district", "district_county", "urban_area"), year = c("2018"), matchWith = c("name", "id", "number"), scale = c("20", "50", "500"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
checkNamesUS(id, unit = c("country", "region", "division", "state", "county", "district", "district_county", "urban_area"), year = c("2018"), matchWith = c("name", "id", "number"), scale = c("20", "50", "500"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
id |
character vector with names |
unit |
the type of USA statistical unit to check |
year |
year of the analysis |
matchWith |
the type of id to check if |
scale |
the scale of the map |
return_logical |
a logical value indicating whether nomatched id are returned. |
print |
a logical value indicating whether print the nomatched names |
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
The function provides a check between id names in the dataset and the USA unit. unit
starts from the largest aggregate, "country", to the smallest, "district". Since unit can change over the years, the year of the data has to be provided.
The single state can be coded in different ways, with names, id or number.
Returns a string vector with nomatched names or a boolean vector indicating whether or not the id matched.
checkNamesIT
, checkNamesEU
, checkNamesWR
data("popUS") ck <- checkNamesUS(popUS$id, unit = "state")
data("popUS") ck <- checkNamesUS(popUS$id, unit = "state")
Check the differences between the names (or codes) given in input and the names (or codes) of the worldwide countries.
checkNamesWR(id, unit = c("country", "nato", "ocde", "continent", "region", "subregion", "region_wb", "type_income", "type_economy"), matchWith = c("country", "iso2", "iso3", "iso3_eh", "iso3_numeric", "iso3_un", "iso2_wb", "iso3_wb", "name_formal", "name_wb"), res = c("low", "hi"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
checkNamesWR(id, unit = c("country", "nato", "ocde", "continent", "region", "subregion", "region_wb", "type_income", "type_economy"), matchWith = c("country", "iso2", "iso3", "iso3_eh", "iso3_numeric", "iso3_un", "iso2_wb", "iso3_wb", "name_formal", "name_wb"), res = c("low", "hi"), return_logical = FALSE, print = TRUE, use_internet = TRUE)
id |
character vector with names or codes |
||||||||||||||||||||
unit |
the type of world statistical unit |
||||||||||||||||||||
matchWith |
the type of id to check:
|
||||||||||||||||||||
res |
map resolution |
||||||||||||||||||||
return_logical |
a logical value indicating whether nomatched id are returned |
||||||||||||||||||||
print |
a logical value indicating whether print the nomatched names |
||||||||||||||||||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
The function provides a check between id name in the dataset and the worldwide country names. The single unit can be coded in different ways, with names, id or iso standards.
Returns a string vector with no matched names or a boolean vector indicating whether or not the id matched.
Alessio Serafini
checkNamesIT
, checkNamesEU
, checkNamesUS
data("popWR") ck <- checkNamesWR(id = popWR$country, matchWith = "country") ck ck1 <- checkNamesWR(id = popWR$country_code, matchWith = "iso3", return_logical = TRUE) ck1
data("popWR") ck <- checkNamesWR(id = popWR$country, matchWith = "country") ck ck1 <- checkNamesWR(id = popWR$country_code, matchWith = "iso3", return_logical = TRUE) ck1
UK
Creates an object with data and coordinates of class DE
for Germany statistical units to use with mapping
functions or available in other R "maps" packages.
DE(data, colID = NULL, unit = c("state", "district", "municipal", "municipality"), matchWith = c("name", "code", "code_full"), subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
DE(data, colID = NULL, unit = c("state", "district", "municipal", "municipality"), matchWith = c("name", "code", "code_full"), subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
data |
a data.frame object with variables to display |
||||||
colID |
character value or columns number indicating the column with unit names or codes |
||||||
unit |
the type of Italian statistical unit |
||||||
matchWith |
the type of id to check:
|
||||||
subset |
a formula indicating the condition to subset the data, see the Details |
||||||
add |
a formula to add new transformed variables starting from the variables in the |
||||||
new_var_names |
a character value or vector indicating the names of the new variables created in |
||||||
aggregation_fun |
function to use when data are aggregated |
||||||
aggregation_unit |
variable name by which the unit are aggregated |
||||||
aggregation_var |
variable name with value to aggregate |
||||||
facets |
variable(s) name to split the data |
||||||
check.unit.names |
a logical value indicating if the |
||||||
dir |
local directory in which shape files are stored |
||||||
use_cache |
a logical value indicating whether use the cache |
||||||
print |
a logical value indicating whether print the nomatched names |
||||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
||||||
crs |
coordinate reference system. Look at |
The function links (automatically) the id in the data
and the coordinates for the given unit
.
Since the names (or codes) provided in the data
given in input must be checked with the unit
names (or codes) available in the package, the check.unit.names
provides a preliminary check.
subset
provide an expression to subset the data
, using a formula with the logical operators. For example, sub-samples of the data can be selected as follows: ~I("Variable 1" == "condition 1" & "Variable 2" != "condition 2")
or for example, ~I("Variable 1" > "condition 1" | "Variable 2" != "condition 2")
.
An object of class DE
, with data and coordinates to use in functions which perform map.
data("popDE") de <- DE(data = popDE, colID = "code_state", unit = "state", matchWith = "code_full") ### Adding two varaibles de2 <- DE(data = popDE, colID = "code_state", unit = "state", matchWith = "code_full", add = ~I(population_2020/1000) + I(population_2020/100) ) ### Adding to variables and names de3 <- DE(data = popDE, colID = "code_state", unit = "state", matchWith = "code_full", add = ~I(population_2020/1000) + I(population_2020/100), new_var_names = c("ratio1", "ratio2"))
data("popDE") de <- DE(data = popDE, colID = "code_state", unit = "state", matchWith = "code_full") ### Adding two varaibles de2 <- DE(data = popDE, colID = "code_state", unit = "state", matchWith = "code_full", add = ~I(population_2020/1000) + I(population_2020/100) ) ### Adding to variables and names de3 <- DE(data = popDE, colID = "code_state", unit = "state", matchWith = "code_full", add = ~I(population_2020/1000) + I(population_2020/100), new_var_names = c("ratio1", "ratio2"))
EU
Creates an object with data and coordinates of class EU
for European countries to use with mapping
functions or available in other R "maps" packages.
EU(data, colID = NULL, 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"), show_eu = TRUE, subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
EU(data, colID = NULL, 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"), show_eu = TRUE, subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
data |
a data.frame object with variables to display |
||||||||||
colID |
character value or columns number indicating the column with unit names |
||||||||||
unit |
the type of European statistical unit |
||||||||||
year |
year of the analysis |
||||||||||
matchWith |
the type of id to check:
|
||||||||||
scale |
the scale of the map |
||||||||||
show_eu |
logical value set to TRUE indicating if the entire map is drawn or only the coordinates linked to the input data |
||||||||||
subset |
a formula indicating the condition to subset the data, see the Details |
||||||||||
add |
a formula to add new transformed variables starting from the variables in the |
||||||||||
new_var_names |
a character value or vector indicating the names of the new variables created in |
||||||||||
aggregation_fun |
function to use when data are aggregated |
||||||||||
aggregation_unit |
variable name by which the unit are aggregated |
||||||||||
aggregation_var |
variable name with value to aggregate |
||||||||||
facets |
variable(s) name to split the data |
||||||||||
check.unit.names |
a logical value indicating if the |
||||||||||
dir |
local directory in which shape files are stored |
||||||||||
use_cache |
a logical value indicating whether use the cache |
||||||||||
print |
a logical value indicating whether print the nomatched names |
||||||||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
||||||||||
crs |
coordinate reference system. Look at |
The function links (automatically) the id in the data
and the coordinates for the given unit
.
Since the names (or codes) provided in the data
given in input must be checked with the unit
names (or codes) available in the package (as provided by Eurostat), the check.unit.names
provides a preliminary check.
subset
provide an expression to subset the data
, using a formula with the logical operators. For example, sub-samples of the data can be selected as follows: ~I("Variable 1" == "condition 1" & "Variable 2" != "condition 2")
or for example, ~I("Variable 1" > "condition 1" | "Variable 2" != "condition 2")
.
An object of class EU
, with data and coordinates to use in functions which perform map.
data("popEU") popEU <- popEU euNuts2 <- EU(data = popEU, colID = "GEO", unit = "nuts2",matchWith = "id") str(euNuts2) euNuts2_1 <- EU(data = popEU, colID = "GEO", unit = "nuts2",matchWith = "id", add = ~I(male/total) + I(female/total)) str(euNuts2_1) euNuts2_2 <- EU(data = popEU, colID = "GEO", unit = "nuts2",matchWith = "id", add = ~I(male/total) + I(female/total), new_var_names = c("Per_Male", "Per_Female")) str(euNuts2_2)
data("popEU") popEU <- popEU euNuts2 <- EU(data = popEU, colID = "GEO", unit = "nuts2",matchWith = "id") str(euNuts2) euNuts2_1 <- EU(data = popEU, colID = "GEO", unit = "nuts2",matchWith = "id", add = ~I(male/total) + I(female/total)) str(euNuts2_1) euNuts2_2 <- EU(data = popEU, colID = "GEO", unit = "nuts2",matchWith = "id", add = ~I(male/total) + I(female/total), new_var_names = c("Per_Male", "Per_Female")) str(euNuts2_2)
FR
Creates an object with data and coordinates of class FR
for France statistical units to use with mapping
functions or available in other R "maps" packages.
FR(data, colID = NULL, unit = c("region"), year = c("2021", "2020", "2019"), matchWith = c("name", "code"), subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
FR(data, colID = NULL, unit = c("region"), year = c("2021", "2020", "2019"), matchWith = c("name", "code"), subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
data |
a data.frame object with variables to display |
|||||
colID |
character value or columns number indicating the column with unit names or codes |
|||||
unit |
the type of Italian statistical unit |
|||||
year |
year of the analysis |
|||||
matchWith |
the type of id to check:
|
|||||
subset |
a formula indicating the condition to subset the data, see the Details |
|||||
add |
a formula to add new transformed variables starting from the variables in the |
|||||
new_var_names |
a character value or vector indicating the names of the new variables created in |
|||||
aggregation_fun |
function to use when data are aggregated |
|||||
aggregation_unit |
variable name by which the unit are aggregated |
|||||
aggregation_var |
variable name with value to aggregate |
|||||
facets |
variable(s) name to split the data |
|||||
check.unit.names |
a logical value indicating if the |
|||||
dir |
local directory in which shape files are stored |
|||||
use_cache |
a logical value indicating whether use the cache |
|||||
print |
a logical value indicating whether print the nomatched names |
|||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
|||||
crs |
coordinate reference system. Look at |
The function links (automatically) the id in the data
and the coordinates for the given unit
.
Since the names (or codes) provided in the data
given in input must be checked with the unit
names (or codes) available in the package, the check.unit.names
provides a preliminary check.
subset
provide an expression to subset the data
, using a formula with the logical operators. For example, sub-samples of the data can be selected as follows: ~I("Variable 1" == "condition 1" & "Variable 2" != "condition 2")
or for example, ~I("Variable 1" > "condition 1" | "Variable 2" != "condition 2")
.
An object of class FR
, with data and coordinates to use in functions which perform map.
data("popFR") fr <- FR(data = popFR) ### Adding two varaibles fr2 <- FR(data = popFR, add = ~I(population/1000) + I(population/100) ) ### Adding to variables and names fr3 <- FR(data = popFR, add = ~I(population/1000) + I(population/100), new_var_names = c("ratio1", "ratio2"))
data("popFR") fr <- FR(data = popFR) ### Adding two varaibles fr2 <- FR(data = popFR, add = ~I(population/1000) + I(population/100) ) ### Adding to variables and names fr3 <- FR(data = popFR, add = ~I(population/1000) + I(population/100), new_var_names = c("ratio1", "ratio2"))
Retrieves Germany statistical unit names.
getNamesDE(unit = c("state", "district", "municipal", "municipality"), all_levels = TRUE)
getNamesDE(unit = c("state", "district", "municipal", "municipality"), all_levels = TRUE)
unit |
the type of statistical units |
all_levels |
a logical value indicating if all levels are returned or only the unit names |
A character vector or a data frame with unit names and corresponding associated levels
getNamesIT
, getNamesEU
, getNamesWR
, getNamesUK
getNamesDE() getNamesDE(unit = "district") getNamesDE(unit = "district", all_levels = FALSE)
getNamesDE() getNamesDE(unit = "district") getNamesDE(unit = "district", all_levels = FALSE)
Retrieves European statistical unit names.
getNamesEU(year = c("2021","2016", "2013", "2010", "2006", "2003"), unit = c("nuts0", "nuts1", "nuts2", "nuts3"), id = FALSE, all_levels = TRUE)
getNamesEU(year = c("2021","2016", "2013", "2010", "2006", "2003"), unit = c("nuts0", "nuts1", "nuts2", "nuts3"), id = FALSE, all_levels = TRUE)
year |
year of the analysis |
unit |
the type of statistical unit |
id |
boolean value indicating whether the ids are returned instead of names |
all_levels |
a logical value indicating if all levels are returned or only the unit names |
A character vector or a data frame with unit names and corresponding associated levels.
getNamesIT
, getNamesUS
, getNamesWR
, getNamesUK
, getNamesDE
getNamesEU() getNamesEU(unit = "nuts1") getNamesEU(unit = "nuts1", all_levels = FALSE, id = FALSE) getNamesEU(unit = "nuts1", all_levels = FALSE, id = TRUE)
getNamesEU() getNamesEU(unit = "nuts1") getNamesEU(unit = "nuts1", all_levels = FALSE, id = FALSE) getNamesEU(unit = "nuts1", all_levels = FALSE, id = TRUE)
Retrieves France statistical unit names.
getNamesFR(year = c("2021", "2020", "2019"), unit = c("region"), all_levels = TRUE)
getNamesFR(year = c("2021", "2020", "2019"), unit = c("region"), all_levels = TRUE)
year |
year of the analysis |
unit |
the type of statistical units |
all_levels |
a logical value indicating if all levels are returned or only the unit names |
A character vector or a data frame with unit names and corresponding associated levels
getNamesIT
, getNamesEU
, getNamesWR
, getNamesDE
getNamesFR() getNamesFR(all_levels = FALSE)
getNamesFR() getNamesFR(all_levels = FALSE)
Retrieves Italian statistical unit names.
getNamesIT(year = c("2021","2020", "2019", "2018", "2017"), unit = c("ripartizione", "regione", "provincia", "comune"), all_levels = TRUE)
getNamesIT(year = c("2021","2020", "2019", "2018", "2017"), unit = c("ripartizione", "regione", "provincia", "comune"), all_levels = TRUE)
year |
year of the analysis |
unit |
the type of Italian statistical unit |
all_levels |
a logical value indicating if all levels are returned or only the unit names |
A character vector or a data frame with unit names and corresponding associated levels.
getNamesEU
, getNamesUS
, getNamesWR
, getNamesUK
, getNamesDE
getNamesIT() getNamesIT(unit = "provincia") getNamesIT(unit = "provincia", all_levels = FALSE)
getNamesIT() getNamesIT(unit = "provincia") getNamesIT(unit = "provincia", all_levels = FALSE)
Retrieves United Kingdom statistical unit names.
getNamesUK(year = c("2020", "2019"), unit = c("country", "county"), all_levels = TRUE)
getNamesUK(year = c("2020", "2019"), unit = c("country", "county"), all_levels = TRUE)
year |
year of the analysis |
unit |
the type of statistical units |
all_levels |
a logical value indicating if all levels are returned or only the unit names |
A character vector or a data frame with unit names and corresponding associated levels
getNamesIT
, getNamesEU
, getNamesWR
, getNamesDE
getNamesUK() getNamesUS(unit = "county") getNamesUK(unit = "county", all_levels = FALSE)
getNamesUK() getNamesUS(unit = "county") getNamesUK(unit = "county", all_levels = FALSE)
Retrieves USA statistical unit names.
getNamesUS(year = "2018", unit = c("region", "division","state", "county", "district", "district_county", "urban_area"), id = FALSE, all_levels = TRUE)
getNamesUS(year = "2018", unit = c("region", "division","state", "county", "district", "district_county", "urban_area"), id = FALSE, all_levels = TRUE)
year |
year of the analysis |
unit |
the type of statistical units |
id |
boolean value indicating whether the ids are returned instead of names |
all_levels |
a logical value indicating if all levels are returned or only the unit names |
A character vector or a data frame with unit names and corresponding associated levels
getNamesIT
, getNamesEU
, getNamesWR
, getNamesUK
, getNamesDE
getNamesUS() getNamesUS(unit = "state") getNamesUS(unit = "state", all_levels = FALSE) getNamesUS(unit = "county") getNamesUS(unit = "county", all_levels = FALSE)
getNamesUS() getNamesUS(unit = "state") getNamesUS(unit = "state", all_levels = FALSE) getNamesUS(unit = "county") getNamesUS(unit = "county", all_levels = FALSE)
Retrieves world country names, ids and iso.
getNamesWR(unit = c("all","country", "name_formal", "name_wb", "iso2", "iso3", "iso3_eh", "iso3_numeric", "iso3_un", "iso2_wb", "iso3_wb"))
getNamesWR(unit = c("all","country", "name_formal", "name_wb", "iso2", "iso3", "iso3_eh", "iso3_numeric", "iso3_un", "iso2_wb", "iso3_wb"))
unit |
the type of names |
A character vector or a data frame with unit names and corresponding associated levels.
getNamesIT
, getNamesUS
, getNamesEU
, getNamesUK
, getNamesDE
getNamesWR() getNamesWR("iso3")
getNamesWR() getNamesWR("iso3")
IT
Creates an object with data and coordinates of class IT
for Italy to use with mapping
functions or available in other R "maps" packages.
IT(data, colID = NULL, unit = c("none","ripartizione", "regione", "provincia", "comune"), year = c("2021","2020","2019", "2018", "2017"), matchWith = c("name", "code","number"), show_it = TRUE, subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
IT(data, colID = NULL, unit = c("none","ripartizione", "regione", "provincia", "comune"), year = c("2021","2020","2019", "2018", "2017"), matchWith = c("name", "code","number"), show_it = TRUE, subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
data |
a data.frame object with variables to display |
||||||
colID |
character value or columns number indicating the column with unit names or codes |
||||||
unit |
the type of Italian statistical unit |
||||||
year |
year of the analysis |
||||||
matchWith |
the type of id to check:
|
||||||
show_it |
logical value set to TRUE indicating if the entire map is drawn or only the coordinates linked to the input data |
||||||
subset |
a formula indicating the condition to subset the data, see the Details |
||||||
add |
a formula to add new transformed variables starting from the variables in the |
||||||
new_var_names |
a character value or vector indicating the names of the new variables created in |
||||||
aggregation_fun |
function to use when data are aggregated |
||||||
aggregation_unit |
variable name by which the unit are aggregated |
||||||
aggregation_var |
variable name with value to aggregate |
||||||
facets |
variable(s) name to split the data |
||||||
check.unit.names |
a logical value indicating if the |
||||||
dir |
local directory in which shape files are stored |
||||||
use_cache |
a logical value indicating whether use the cache |
||||||
print |
a logical value indicating whether print the nomatched names |
||||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
||||||
crs |
coordinate reference system. Look at |
The function links (automatically) the id in the data
and the coordinates for the given unit
.
Since the names (or codes) provided in the data
given in input must be checked with the unit
names (or codes) available in the package (as provided by ISTAT), the check.unit.names
provides a preliminary check.
subset
provide an expression to subset the data
, using a formula with the logical operators. For example, sub-samples of the data can be selected as follows: ~I("Variable 1" == "condition 1" & "Variable 2" != "condition 2")
or for example, ~I("Variable 1" > "condition 1" | "Variable 2" != "condition 2")
.
An object of class IT
, with data and coordinates to use in functions which perform map.
data("popIT") it <- IT(data = popIT, unit = "provincia", year = "2019") ### Adding two varaibles it2 <- IT(data = popIT, unit = "provincia", year = "2019", add = ~I(maschi/totale) + I(femmine/totale) ) ### Adding to variables and names it3 <- IT(data = popIT, unit = "provincia", year = "2019", add = ~I(maschi/totale) + I(femmine/totale), new_var_names = c("Per_Maschi", "Per_Femmine") )
data("popIT") it <- IT(data = popIT, unit = "provincia", year = "2019") ### Adding two varaibles it2 <- IT(data = popIT, unit = "provincia", year = "2019", add = ~I(maschi/totale) + I(femmine/totale) ) ### Adding to variables and names it3 <- IT(data = popIT, unit = "provincia", year = "2019", add = ~I(maschi/totale) + I(femmine/totale), new_var_names = c("Per_Maschi", "Per_Femmine") )
Loads and returns names, id, and coordinates for Germany statistical unit, to use with mapping
functions and other "map" functions that accept an sf
object.
loadCoordDE(unit = c("state", "district", "municipal", "municipality"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
loadCoordDE(unit = c("state", "district", "municipal", "municipality"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
unit |
the type of Italian statistical unit to link |
unit_subset |
character vector of unit names to extract |
matchWith |
the type of id |
dir |
local directory in which shape files are stored |
use_cache |
a logical value indicating whether to use the cache |
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
crs |
coordinate reference system. Look at |
Coordinates are download from the Github repo https://github.com/mappinguniverse/geospatial from DE folder https://github.com/mappinguniverse/geospatial/tree/master/DE.
If unit
is not specified, state borders are loaded.
A data.frame object with column indicating names, id, and the geometry to map.
Alessio Serafini
https://github.com/mappinguniverse/geospatial
loadCoordEU
, loadCoordWR
, loadCoordUS
, loadCoordUK
DE_coords = loadCoordDE(unit = "state") str(DE_coords) ## Load subset coords_de <- loadCoordDE(unit = "district", unit_subset = "bayern", matchWith = "state")
DE_coords = loadCoordDE(unit = "state") str(DE_coords) ## Load subset coords_de <- loadCoordDE(unit = "district", unit_subset = "bayern", matchWith = "state")
Loads and returns names, id, and coordinates for European countries, to use with mapping
functions and other "map" functions that accept an sf
object.
loadCoordEU(unit = c("nuts0", "nuts1", "nuts2", "nuts3", "urau"), year = c("2021","2016", "2013", "2010", "2006", "2003"), scale = c("20", "60"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
loadCoordEU(unit = c("nuts0", "nuts1", "nuts2", "nuts3", "urau"), year = c("2021","2016", "2013", "2010", "2006", "2003"), scale = c("20", "60"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
unit |
the type of European statistical unit to link |
year |
year of the analysis |
scale |
the scale of the map |
unit_subset |
character vector of unit names to extract |
matchWith |
the type of id |
dir |
local directory in which shape files are stored |
use_cache |
a logical value indicating whether to use the cache |
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
crs |
coordinate reference system. Look at |
Coordinates are download from the Github repo https://github.com/mappinguniverse/geospatial from EU folder https://github.com/mappinguniverse/geospatial/tree/master/EU.
If unit
is not specified, borders of the European countries are loaded.
A data.frame object with columns indicating names, ids, iso and the geometries to map.
Alessio Serafini
https://github.com/mappinguniverse/geospatial
loadCoordIT
, loadCoordWR
, loadCoordDE
, loadCoordUK
EU_coords = loadCoordEU(unit = "nuts0") str(EU_coords) coords_eu_it_de <- loadCoordEU(unit = "nuts0", unit_subset = c("italy", "germany")) str(coords_eu_it_de)
EU_coords = loadCoordEU(unit = "nuts0") str(EU_coords) coords_eu_it_de <- loadCoordEU(unit = "nuts0", unit_subset = c("italy", "germany")) str(coords_eu_it_de)
Loads and returns names, id, and coordinates for France statistical unit, to use with mapping
functions and other "map" functions that accept an sf
object.
loadCoordFR(unit = c("region"), year = c("2021", "2020", "2019"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
loadCoordFR(unit = c("region"), year = c("2021", "2020", "2019"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
unit |
the type of Italian statistical unit to link |
year |
year of the analysis |
unit_subset |
character vector of unit names to extract |
matchWith |
the type of id |
dir |
local directory in which shape files are stored |
use_cache |
a logical value indicating whether to use the cache |
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
crs |
coordinate reference system. Look at |
Coordinates are download from the Github repo https://github.com/mappinguniverse/geospatial from FR folder https://github.com/mappinguniverse/geospatial/tree/master/FR.
If unit
is not specified, country borders are loaded.
A data.frame object with column indicating names, id, and the geometry to map.
FR_coords = loadCoordFR(unit = "region", year = "2020") str(FR_coords)
FR_coords = loadCoordFR(unit = "region", year = "2020") str(FR_coords)
Loads and returns names, ids, and coordinates for Italian statistical unit, ready to use with mapping
functions and other "map" functions that accept an sf
object.
loadCoordIT(unit = c("none","ripartizione", "regione", "provincia","comune"), year = c("2021","2020", "2019", "2018", "2017"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
loadCoordIT(unit = c("none","ripartizione", "regione", "provincia","comune"), year = c("2021","2020", "2019", "2018", "2017"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
unit |
the type of Italian statistical unit to link |
year |
year of the analysis |
unit_subset |
character vector of unit names to extract |
matchWith |
the type of id |
dir |
local directory in which shape files are stored |
use_cache |
a logical value indicating whether to use the cache |
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
crs |
coordinate reference system. Look at |
Coordinates are download from the Github repo https://github.com/mappinguniverse/geospatial from IT folder https://github.com/mappinguniverse/geospatial/tree/master/IT.
unit="none"
(default) indicates that the border of Italy is returned.
A data.frame object with column indicating names, id, and the geometry to map.
Alessio Serafini
https://github.com/mappinguniverse/geospatial
loadCoordEU
, loadCoordWR
, loadCoordUS
, loadCoordDE
, loadCoordUK
IT_coords = loadCoordIT(unit = "regione", year = "2020") str(IT_coords) ## Italy IT_coords = loadCoordIT() str(IT_coords) coords_it<- loadCoordIT(unit = "regione", unit_subset = c(5, 10), matchWith = "number") str(coords_it)
IT_coords = loadCoordIT(unit = "regione", year = "2020") str(IT_coords) ## Italy IT_coords = loadCoordIT() str(IT_coords) coords_it<- loadCoordIT(unit = "regione", unit_subset = c(5, 10), matchWith = "number") str(coords_it)
Loads and returns names, id, and coordinates for United Kingdom statistical unit, to use with mapping
functions and other "map" functions that accept an sf
object.
loadCoordUK(unit = c("country", "county"), year = c("2020", "2019"), scale = c("500", "20"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
loadCoordUK(unit = c("country", "county"), year = c("2020", "2019"), scale = c("500", "20"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
unit |
the type of Italian statistical unit to link |
year |
year of the analysis |
scale |
the scale of the map |
unit_subset |
character vector of unit names to extract |
matchWith |
the type of id |
dir |
local directory in which shape files are stored |
use_cache |
a logical value indicating whether to use the cache |
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
crs |
coordinate reference system. Look at |
Coordinates are download from the Github repo https://github.com/mappinguniverse/geospatial from UK folder https://github.com/mappinguniverse/geospatial/tree/master/UK.
If unit
is not specified, country borders are loaded.
A data.frame object with column indicating names, id, and the geometry to map.
Alessio Serafini
https://github.com/mappinguniverse/geospatial
loadCoordEU
, loadCoordWR
, loadCoordUS
, loadCoordDE
UK_coords = loadCoordUK(unit = "country", year = "2020") str(UK_coords) ## Load subset coords_uk <- loadCoordUK(unit = "county", unit_subset = "england", matchWith = "country") coords_uk <- loadCoordUK(unit = "county", unit_subset = "hartlepool", matchWith = "county")
UK_coords = loadCoordUK(unit = "country", year = "2020") str(UK_coords) ## Load subset coords_uk <- loadCoordUK(unit = "county", unit_subset = "england", matchWith = "country") coords_uk <- loadCoordUK(unit = "county", unit_subset = "hartlepool", matchWith = "county")
Loads and returns names, ids, and coordinates for USA, to use with mapping
functions and other "map" functions that accept an sf
object.
loadCoordUS(unit = c("country", "region", "division", "state", "county", "district", "district_county", "urban_area"), year = c("2018"), scale = c("20", "50", "500"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
loadCoordUS(unit = c("country", "region", "division", "state", "county", "district", "district_county", "urban_area"), year = c("2018"), scale = c("20", "50", "500"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
unit |
type of USA unit to link |
year |
year of the analysis |
scale |
the scale of the map |
unit_subset |
character vector of unit names to extract |
matchWith |
the type of id |
dir |
local directory in which shape files are stored |
use_cache |
a logical value indicating whether to use the cache |
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
crs |
coordinate reference system. Look at |
Coordinates are downloaded from the Github repo https://github.com/mappinguniverse/geospatial from US folder https://github.com/mappinguniverse/geospatial/tree/master/US.
If unit
is not specified, borders of the USA countries are loaded.
A data.frame object with columns indicating names, ids, and the geometry to map.
Alessio Serafini
https://github.com/mappinguniverse/geospatial
loadCoordIT
, loadCoordWR
, loadCoordDE
, loadCoordUK
, , loadCoordEU
US_coords = loadCoordUS(unit = "state") str(US_coords) coords_us<- loadCoordUS(unit = "state", unit_subset = c("Florida", "California"))
US_coords = loadCoordUS(unit = "state") str(US_coords) coords_us<- loadCoordUS(unit = "state", unit_subset = c("Florida", "California"))
Loads and returns names, ids, iso, and coordinates for world countries, ready to use with mapping
functions and other "map" functions that accept an sf
object.
loadCoordWR(unit = c("country", "nato", "ocde", "continent", "region", "subregion", "region_wb", "type_income", "type_economy"), res = c("low", "hi"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
loadCoordWR(unit = c("country", "nato", "ocde", "continent", "region", "subregion", "region_wb", "type_income", "type_economy"), res = c("low", "hi"), unit_subset = NULL, matchWith = NULL, dir = NULL, use_cache = TRUE, use_internet = TRUE, crs = NULL)
unit |
the type of world statistical unit |
res |
resolution |
unit_subset |
character vector of unit names to extract |
matchWith |
the type of id |
dir |
local directory in which shape files are stored |
use_cache |
a logical value indicating whether to use the cache |
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
crs |
coordinate reference system. Look at |
Coordinates are download from the Github repo https://github.com/mappinguniverse/geospatial from world folder https://github.com/mappinguniverse/geospatial/tree/master/world.
A data.frame object with column indicating names, id, iso and the geometry to map.
Alessio Serafini
https://github.com/mappinguniverse/geospatial
loadCoordIT
, loadCoordEU
, loadCoordUS
, loadCoordDE
, loadCoordUK
WR_coords = loadCoordWR(res = "low") str(WR_coords, 1) WR_ocde = loadCoordWR(unit = "ocde",res = "low") str(WR_ocde, 1) WR_continent = loadCoordWR(unit = "continent",res = "low") str(WR_continent, 1)
WR_coords = loadCoordWR(res = "low") str(WR_coords, 1) WR_ocde = loadCoordWR(unit = "ocde",res = "low") str(WR_ocde, 1) WR_continent = loadCoordWR(unit = "continent",res = "low") str(WR_continent, 1)
Returns different color palette
mapPalette(type, nclass = NULL )
mapPalette(type, nclass = NULL )
type |
character value indicating the color palette |
nclass |
number of classes |
A character vector with palettes.
Function to produce static maps from an object of class sf
, IT
, EU
, US
, or WR
.
mapping(data = NULL, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo","bar"), add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options(), ...)
mapping(data = NULL, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo","bar"), add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options(), ...)
data |
an object of class |
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 |
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 aggregate |
options |
a list with options using |
... |
further arguments |
It is a general function to map data. We can externally provide the coordinates with the variable to map, or the coordinates and the data to link.
If coordinates are provided and data
is NULL
, the function map the var
in coordinates
. If data
is not NULL
, then the function link data and coordinates, and the var
is get from the data provided in input.
If only data
are provided without coordinates, the function search the colID
among the the coordinates dataset provided by https://github.com/mappinguniverse/geospatial, to link the ids with coordinates. For search look at SearchNames
Returns a map. For tmap
type, the function also returns a tmap
object.
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).
mappingWR
,mappingIT
, mappingEU
library(dplyr) library(sf) data("popIT") popIT <- popIT coords <- loadCoordIT(unit = "provincia", year = '2019') cr <- left_join(coords, popIT, by = c( "provincia" = "ID")) ############### # Statics # ############### mapping(cr) mapping(cr, var = "maschi") nc = st_read(system.file("shape/nc.shp", package="sf")) class(nc) mapping(nc) mapping(nc, var = "AREA", options = mapping.options(legend.position = c("left", "bottom"))) ############### # Interactive # ############### mapping(cr, type = "interactive") mapping(cr, var = "maschi", type = "interactive") nc = st_read(system.file("shape/nc.shp", package="sf")) class(nc) mapping(nc, type = "interactive") mapping(nc, var = "AREA", type = "interactive")
library(dplyr) library(sf) data("popIT") popIT <- popIT coords <- loadCoordIT(unit = "provincia", year = '2019') cr <- left_join(coords, popIT, by = c( "provincia" = "ID")) ############### # Statics # ############### mapping(cr) mapping(cr, var = "maschi") nc = st_read(system.file("shape/nc.shp", package="sf")) class(nc) mapping(nc) mapping(nc, var = "AREA", options = mapping.options(legend.position = c("left", "bottom"))) ############### # Interactive # ############### mapping(cr, type = "interactive") mapping(cr, var = "maschi", type = "interactive") nc = st_read(system.file("shape/nc.shp", package="sf")) class(nc) mapping(nc, type = "interactive") mapping(nc, var = "AREA", type = "interactive")
Set or retrieve default values used in mapping functions availables in mapping package.
mapping.options(...)
mapping.options(...)
... |
A single character vector, or a named list. The form |
The function change globally the option for the current R session, and locally if used in the mapping
function, with the options
argument, for example, options = mapping.options(legend.frame = FALSE, "title.position" = "left")
.
Many different options are used for the function in tmap package. For more details, look at tm_layout
, tm_borders
, and tm_fill
.
Available options are the following:
palette.cont = "YlGnBu"
palette for countinuous data
palette.cat = "Accent"
palette for categorical data
palette.cont.vector = NULL
a string vector with color names for countinuous data
palette.cont.vector = NULL
a string vector with color names for categorical data
nclass = 5
number of classes for countinuous data
check.unit.names = TRUE
a ogical value indicating whether the input id names are checked before the link with the coordinates
use_cache = TRUE
a ogical value indicating whether the cache is used to load the shape file
use_internet = TRUE
a ogical value indicating whether the data are downloaded from internet or whether a internet connection is available
alpha = 1
transparency
breaks = NULL
a numerical value indicating the breaks
interval.closure = "left"
a ogical value indicating where the interval are closed
labels = NULL
a character vector with labels of the classes
NA.color = "grey"
color for NA
values
NA.text = "Missing"
label for NA
values
col.style = "order"
type of color scale for numeric data. For other method look ad tm_fill
map.frame = TRUE
a logical value indicating whether the frame is drawn
border.lwd = 1
line width of the borders
border.col = "black"
color of the borders
border.type = "solid"
border type
border.alpha = NA
trasparency of the borders
title = NULL
main title
title.position = "center"
main title position
title.color = "black"
color of main title
title.fontface = 1
main title font face
title.size = 1
main title size
legend.title = NA
title of the legend
legend.show = TRUE
a logical value indicating whether include the legend
legend.only = FALSE
a logical value indicating whether include the legend without map
legend.position = c("right","top")
legend position
legend.digits = 5
legend digits
legend.outside = FALSE
a logical value indicating whether the legend is included outside the map
legend.outside.facetes = TRUE
a logical value indicating whether the legend is included outside the facetes
legend.width = 1
width of the legend
legend.title.position = c("right","top")
legend title position
legend.title.size = 1
legend title size
legend.title.fontface = 1
legend title font space
legend.title.color = "black"
legend title color
legend.text.color = "black"
legend title color
legend.text.size = 0.5
legend title color size
legend.text.align = "left"
legend.text.fontface = 1
legend.frame = TRUE
a logical value indicating whether the frame is drawn for the legend
legend.decimal.mark = "."
legend.format = "fg"
legend.big.mark = ","
legend.text.separator = "-"
facets.free.scale = FALSE
facetes.cols = NA
facetes.rows = NA
interactive.tiles = "CartoDB.Positron"
interactive.popup.vars = NULL
interactive.popup.id = TRUE
interactive.popup.closeButton = TRUE
interactive.popup.width.max = 150
interactive.popup.width.min = 35
interactive.highlight.weight = 3
interactive.highlight.color = "black"
interactive.highlight.alpha = 1
interactive.highlight.front = TRUE
interactive.control.collapse = TRUE
interactive.layer.control.position = c("left", "top")
interactive.hovered.id = TRUE
text.size = 0.5
text.col = "black"
text.fontface = 1
text.shadow = FALSE
text.alpha = NA
credits.source = NULL
credits.author = NULL
credits.size = 0.7
credits.fontface = NA
credits.color = "black"
credits.align = "left"
credits.position = c("left", "bottom")
popup.vars = NA
a character vector indicating the variable to popoup in interactive maps
compass = NULL
a character vector indicatin the type of compass (look at tm_layout
)
style = "white"
style (look at tm_style
)
crs = NULL
Options may be reset using mapping.options()
.
Return a list with options.
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).
mapping.options() # A single options mapping.options("title.position") # Globally mapping.options("title.position" = "left") mapping.options("title.position")
mapping.options() # A single options mapping.options("title.position") # Globally mapping.options("title.position" = "left") mapping.options("title.position")
Function to produce static maps for Germany statistical unit.
mappingDE(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("state", "district", "municipal", "municipality"), matchWith = c("name", "code", "code_full"), dir = NULL, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
mappingDE(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("state", "district", "municipal", "municipality"), matchWith = c("name", "code", "code_full"), dir = NULL, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
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 Italian statistical unit |
||||||
matchWith |
the type of id to check:
|
||||||
dir |
local directory in which shape files are stored |
||||||
add_text |
character name indicating the column with text labels |
||||||
subset |
a formula indicating the condition to subset the data. See the details section |
||||||
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 |
If data
is a object of class "DE" generated using the DE
function, the argument unit
, 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 municipal
, we will have variables for larger aggregate unit, that is district
and state
variables. Look at DE
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")
.
Return a map. For tmap
type, the function also returns a tmap
object.
mappingWR
,mappingEU
, mappingUS
, mappingUK
data("popDE") de <- DE(data = popDE, colID = "code_state", unit = "state", matchWith = "code_full", check.unit.names = FALSE) ############### # Statics # ############### mappingDE(data = de, var = "population_2020") mappingDE(data = de, var = "population_2020", subset = ~I(state == "bayern")) ############### # Interactive # ############### mappingDE(data = de, var = "population_2020", type = "interactive") mappingDE(data = de, var = "population_2020", subset = ~I(state == "bayern"), type = "interactive")
data("popDE") de <- DE(data = popDE, colID = "code_state", unit = "state", matchWith = "code_full", check.unit.names = FALSE) ############### # Statics # ############### mappingDE(data = de, var = "population_2020") mappingDE(data = de, var = "population_2020", subset = ~I(state == "bayern")) ############### # Interactive # ############### mappingDE(data = de, var = "population_2020", type = "interactive") mappingDE(data = de, var = "population_2020", subset = ~I(state == "bayern"), type = "interactive")
Function to produce static maps for European statistical unit.
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())
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())
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 |
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")
.
Returns a map. For tmap
type, the function also returns a tmap
object.
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).
mappingWR
,mappingIT
,mappingUS
,mappingDE
,mappingUK
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)
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)
Function to produce static maps for France statistical unit.
mappingFR(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("region"), year = c("2021", "2020", "2019"), matchWith = c("name", "code"), dir = NULL, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
mappingFR(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("region"), year = c("2021", "2020", "2019"), matchWith = c("name", "code"), dir = NULL, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
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 Italian statistical unit |
||||
year |
year of the unit |
||||
matchWith |
the type of id to check:
|
||||
dir |
local directory in which shape files are stored |
||||
add_text |
character name indicating the column with text labels |
||||
subset |
a formula indicating the condition to subset the data. See the details section |
||||
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 |
If data
is a object of class "UK" generated using the UK
function, the arguments unit
, and year
are ignored, because the object already contains the coordinates.
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")
.
Return a map. For tmap
type, the function also returns a tmap
object.
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).
mappingWR
,mappingEU
, mappingUS
, mappingDE
data("popFR") fr <- FR(data = popFR) ############### # Statics # ############### mappingFR(data = fr, var = "population", subset = ~I(region == "corse"))
data("popFR") fr <- FR(data = popFR) ############### # Statics # ############### mappingFR(data = fr, var = "population", subset = ~I(region == "corse"))
Function to produce static maps for Italian statistical unit.
mappingIT(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("none", "ripartizione", "regione", "provincia", "comune"), year = c("2021", "2020", "2019", "2018", "2017"), matchWith = c("name", "code", "number"), dir = NULL, show_it = TRUE, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
mappingIT(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("none", "ripartizione", "regione", "provincia", "comune"), year = c("2021", "2020", "2019", "2018", "2017"), matchWith = c("name", "code", "number"), dir = NULL, show_it = TRUE, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
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 Italian statistical unit |
||||
year |
year of the unit |
||||
matchWith |
the type of id to check:
|
||||
dir |
local directory in which shape files are stored |
||||
show_it |
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 section |
||||
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 |
If data
is a object of class "IT" generated using the IT
function, the arguments unit
, and year
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 provicia
, we will have variables for larger aggregate unit, that is regione
and ripartizione
variables. Look at IT
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")
.
Return a map. For tmap
type, the function also returns a tmap
object.
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).
mappingWR
,mappingEU
,mappingUS
,mappingDE
,mappingUK
data("popIT") it <- IT(data = popIT, unit = "provincia", year = "2019", check.unit.names = FALSE) ############### # Statics # ############### mappingIT(data = it, var = "totale") mappingIT(data = it, var = "totale", subset = ~I(regione == "Lazio")) mappingIT(data = it, var = "totale", facets = "ripartizione") mappingIT(data = it, var = c("maschi","femmine")) mappingIT(data = it, var = "totale", typeStatic = "choro.cart") mappingIT(data = it, var = "totale", aggregation_unit = "ripartizione", aggregation_fun = function(x) sum(x, na.rm = TRUE)) ### Italy it1 <- loadCoordIT() mappingIT(data = it1) ############### # Interactive # ############### mappingIT(data = it, var = "totale", type = "interactive") mappingIT(data = it, var = c("maschi", "femmine"), type = "interactive") mappingIT(data = it, var = "totale", subset = ~I(regione == "Lazio"), type = "interactive") mappingIT(data = it, var = "totale", type = "interactive", aggregation_unit = "ripartizione", aggregation_fun = function(x) sum(x, na.rm = TRUE))
data("popIT") it <- IT(data = popIT, unit = "provincia", year = "2019", check.unit.names = FALSE) ############### # Statics # ############### mappingIT(data = it, var = "totale") mappingIT(data = it, var = "totale", subset = ~I(regione == "Lazio")) mappingIT(data = it, var = "totale", facets = "ripartizione") mappingIT(data = it, var = c("maschi","femmine")) mappingIT(data = it, var = "totale", typeStatic = "choro.cart") mappingIT(data = it, var = "totale", aggregation_unit = "ripartizione", aggregation_fun = function(x) sum(x, na.rm = TRUE)) ### Italy it1 <- loadCoordIT() mappingIT(data = it1) ############### # Interactive # ############### mappingIT(data = it, var = "totale", type = "interactive") mappingIT(data = it, var = c("maschi", "femmine"), type = "interactive") mappingIT(data = it, var = "totale", subset = ~I(regione == "Lazio"), type = "interactive") mappingIT(data = it, var = "totale", type = "interactive", aggregation_unit = "ripartizione", aggregation_fun = function(x) sum(x, na.rm = TRUE))
Function to produce static maps for United Kingdom statistical unit.
mappingUK(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("country", "county"), year = c("2020", "2019"), matchWith = c("name", "code"), scale = c("500", "20"), dir = NULL, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
mappingUK(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("country", "county"), year = c("2020", "2019"), matchWith = c("name", "code"), scale = c("500", "20"), dir = NULL, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
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 Italian statistical unit |
||||
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 |
||||
add_text |
character name indicating the column with text labels |
||||
subset |
a formula indicating the condition to subset the data. See the details section |
||||
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 |
If data
is a object of class "UK" generated using the UK
function, the arguments unit
, and year
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 county
, we will have variables for larger aggregate unit, that is country
variables. Look at UK
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")
.
Return a map. For tmap
type, the function also returns a tmap
object.
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).
mappingWR
,mappingEU
, mappingUS
, mappingDE
data("popUK") uk <- UK(data = popUK, unit = "county", matchWith = "code", check.unit.names = FALSE)
data("popUK") uk <- UK(data = popUK, unit = "county", matchWith = "code", check.unit.names = FALSE)
Function to produce static maps for USA unit.
mappingUS(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("country", "region", "division","state", "county", "district", "district_county", "urban_area"), year = c("2018"), matchWith = c("name", "id", "number"), scale = c("20", "50", "500"), dir = NULL, show_us = TRUE, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
mappingUS(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("country", "region", "division","state", "county", "district", "district_county", "urban_area"), year = c("2018"), matchWith = c("name", "id", "number"), scale = c("20", "50", "500"), dir = NULL, show_us = TRUE, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options())
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 if unit is set to "states" |
scale |
the scale of a map |
dir |
local directory in which shape files are stored |
show_us |
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 section |
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 |
If data
is a object of class "US" generated using the US
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 county
, we will have variables for larger aggregate unit, that is state
and region
variables. Look at US
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")
.
Return a map. For tmap
type, the function also returns a tmap
object.
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).
mappingWR
,mappingIT
,mappingEU
,mappingDE
,mappingUK
data("popUS") us <- US(data = popUS, unit = "state") ############### # Statics # ############### mappingUS(data = us, var = "population") mappingUS(data = us, var = "population", subset = ~I(id == "california" | id == "texas")) mappingUS(data = us, var = "population", subset = ~I(id == "california" | id == "texas"), facets = "id") mappingUS(data = us, var = "population", typeStatic = "choro.cart") ############### # Interactive # ############### mappingUS(data = us, var = "population", type = "interactive") mappingUS(data = us, var = "population", type = "interactive", subset = ~I(id == "california" | id == "texas" | id == "new york" ))
data("popUS") us <- US(data = popUS, unit = "state") ############### # Statics # ############### mappingUS(data = us, var = "population") mappingUS(data = us, var = "population", subset = ~I(id == "california" | id == "texas")) mappingUS(data = us, var = "population", subset = ~I(id == "california" | id == "texas"), facets = "id") mappingUS(data = us, var = "population", typeStatic = "choro.cart") ############### # Interactive # ############### mappingUS(data = us, var = "population", type = "interactive") mappingUS(data = us, var = "population", type = "interactive", subset = ~I(id == "california" | id == "texas" | id == "new york" ))
Function to produce static maps for world countries.
mappingWR(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("country", "nato", "ocde", "continent", "region", "subregion", "region_wb", "type_income", "type_economy"), matchWith = c("country", "iso2", "iso3", "iso3_eh", "iso3_numeric", "iso3_un", "iso2_wb", "iso3_wb", "name_formal", "name_wb"), res = c("low", "hi"), dir = NULL, show_wr = TRUE, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options(legend.position = c("left", "bottom")))
mappingWR(data, var = NULL, colID = NULL, type = c("static", "interactive"), typeStatic = c("tmap", "choro.cart", "typo", "bar"), unit = c("country", "nato", "ocde", "continent", "region", "subregion", "region_wb", "type_income", "type_economy"), matchWith = c("country", "iso2", "iso3", "iso3_eh", "iso3_numeric", "iso3_un", "iso2_wb", "iso3_wb", "name_formal", "name_wb"), res = c("low", "hi"), dir = NULL, show_wr = TRUE, add_text = NULL, subset = NULL, facets = NULL, aggregation_fun = sum, aggregation_unit = NULL, options = mapping.options(legend.position = c("left", "bottom")))
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 world statistical unit |
||||||||||||||||||||
matchWith |
the type of id to check:
|
||||||||||||||||||||
res |
map resolution |
||||||||||||||||||||
dir |
local directory in which shape files are stored |
||||||||||||||||||||
show_wr |
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 section |
||||||||||||||||||||
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 |
If data
is a object of class "WR" generated using the WR
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.
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")
.
Return a map. For tmap
type, the function also returns a tmap
object.
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).
mappingEU
,mappingIT,mappingUS
,mappingDE
,mappingUK
data("popWR") popWR <- popWR wr <- WR(data = popWR, colID = "country_code", matchWith = "iso3_eh", check.unit.names = FALSE, res = "low") ############### # Statics # ############### mappingWR(data = wr, var = "total") mappingWR(data = wr, var = c("male","female")) mappingWR(data = wr, var = "total", subset = ~I(iso2 == "IT")) mappingWR(data = wr, var = "total", subset = ~I(region == "Americas")) mappingWR(data = wr, var = "total", facets = "continent") mappingWR(data = wr, var = "total", subset = ~I(continent == "South America"), facets = "name_wb") mappingWR(data = wr, var = "total", typeStatic = "choro.cart") mappingWR(data = wr, var = "total", aggregation_unit = "continent", aggregation_fun = function(x) sum(x, na.rm = TRUE)) mappingWR(data = wr, var = "total", aggregation_unit = "subregion", aggregation_fun = function(x) sum(x, na.rm = TRUE)) ## World countries wr1 <- loadCoordWR() mappingWR(data = wr1) ############### # Interactive # ############### mappingWR(data = wr, var = "total", type = "interactive") mappingWR(data = wr, var = c("male","female"), type = "interactive") mappingWR(data = wr, var = "total", subset = ~I(iso2 == "IT"), type = "interactive") mappingWR(data = wr, var = "total", subset = ~I(region == "Americas"), type = "interactive") mappingWR(data = wr, var = "total", type = "interactive", aggregation_unit = "continent", aggregation_fun = function(x) sum(x, na.rm = TRUE)) mappingWR(data = wr, var = "total", type = "interactive", aggregation_unit = "subregion", aggregation_fun = function(x) sum(x, na.rm = TRUE))
data("popWR") popWR <- popWR wr <- WR(data = popWR, colID = "country_code", matchWith = "iso3_eh", check.unit.names = FALSE, res = "low") ############### # Statics # ############### mappingWR(data = wr, var = "total") mappingWR(data = wr, var = c("male","female")) mappingWR(data = wr, var = "total", subset = ~I(iso2 == "IT")) mappingWR(data = wr, var = "total", subset = ~I(region == "Americas")) mappingWR(data = wr, var = "total", facets = "continent") mappingWR(data = wr, var = "total", subset = ~I(continent == "South America"), facets = "name_wb") mappingWR(data = wr, var = "total", typeStatic = "choro.cart") mappingWR(data = wr, var = "total", aggregation_unit = "continent", aggregation_fun = function(x) sum(x, na.rm = TRUE)) mappingWR(data = wr, var = "total", aggregation_unit = "subregion", aggregation_fun = function(x) sum(x, na.rm = TRUE)) ## World countries wr1 <- loadCoordWR() mappingWR(data = wr1) ############### # Interactive # ############### mappingWR(data = wr, var = "total", type = "interactive") mappingWR(data = wr, var = c("male","female"), type = "interactive") mappingWR(data = wr, var = "total", subset = ~I(iso2 == "IT"), type = "interactive") mappingWR(data = wr, var = "total", subset = ~I(region == "Americas"), type = "interactive") mappingWR(data = wr, var = "total", type = "interactive", aggregation_unit = "continent", aggregation_fun = function(x) sum(x, na.rm = TRUE)) mappingWR(data = wr, var = "total", type = "interactive", aggregation_unit = "subregion", aggregation_fun = function(x) sum(x, na.rm = TRUE))
Statistical unit names.
data("namesWR") data("namesEU") data("namesIT") data("namesUS") data("namesDE") data("namesFR") data("namesUK")
data("namesWR") data("namesEU") data("namesIT") data("namesUS") data("namesDE") data("namesFR") data("namesUK")
A list with all names divided for year and type of units.
Look at getNamesWR
, getNamesEU
, getNamesIT
, getNamesUS
, getNamesUK
, getNamesDE
, getNamesFR
World Bank, Eurostat, United States Census and Istat
data(namesWR) str(namesWR) data(namesEU) str(namesEU) data(namesIT) str(namesIT) data(namesUS) str(namesUS)
data(namesWR) str(namesWR) data(namesEU) str(namesEU) data(namesIT) str(namesIT) data(namesUS) str(namesUS)
German bund population for year 2020
data("popDE")
data("popDE")
A data frame.
European population for year 2018
data("popEU") data("popEUnuts2")
data("popEU") data("popEUnuts2")
A data frame with 2252 observations on the following 5 variables.
TIME
year
GEO
names
total
total
male
number of male
female
number of female
https://ec.europa.eu/eurostat/data/database
French regions population for year 2021
data("popFR")
data("popFR")
A data frame.
Italian provincia population for year 2018
data("popIT")
data("popIT")
A data frame with 107 observations on the following 4 variables.
ID
names
maschi
number of male
femmine
number of femal
totale
total
Istat
United Kingdome county population for year 2020
data("popUK")
data("popUK")
A data frame.
USA population for year 2019
data("popUS")
data("popUS")
A data frame with 52 observations on the following 2 variables.
id
names
population
total population
https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html
Country pooulation for yeaar 2018
data("popWR")
data("popWR")
A data frame with 269 observations on the following 5 variables.
country
a factor with countries
country_code
a factor with code
total
total
male
number of male
female
number of female
World Bank
Save output from loadCoord
function, sf
objects, IT
, EU
, WR
, and US
in different format
saveObj(obj, name, as = c("RData", "csv", "json", "geojson", "shp"), ...)
saveObj(obj, name, as = c("RData", "csv", "json", "geojson", "shp"), ...)
obj |
Output from |
name |
output name |
as |
format |
... |
further arguments |
No return value.
## Not run: data("popIT") it <- IT(data = popIT, unit = "provincia", year = "2019") saveObj(it, name = "it.RData") ## End(Not run)
## Not run: data("popIT") it <- IT(data = popIT, unit = "provincia", year = "2019") saveObj(it, name = "it.RData") ## End(Not run)
Tax wedge for OCDE countries
data("tax_wedge_ocde")
data("tax_wedge_ocde")
A data frame with 74 observations on the following 7 variables.
country_code
a factor with country code
year
a character vector with year
family_type
a factor with family levels
average_rate_employees_SSC
a numeric vector with Social Securities Contribution by employees
average_rate_employer_SSC
a numeric vector with Social Securities Contribution by employers
net_personal_average_tax_rate
a numeric vector with personal average tax rate
average_tax_wedge
a numeric vector with average tax wedge
OECD (2020), Tax wedge (indicator). doi: 10.1787/cea9eba3-en (Accessed on 30 November 2020). https://data.oecd.org/tax/tax-wedge.htm
data(tax_wedge_ocde) str(tax_wedge_ocde)
data(tax_wedge_ocde) str(tax_wedge_ocde)
UK
Creates an object with data and coordinates of class UK
for United Kindome statistical units to use with mapping
functions or available in other R "maps" packages.
UK(data, colID = NULL, unit = c("country", "county"), year = c("2020", "2019"), matchWith = c("name", "code"), scale = c("500", "20"), subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
UK(data, colID = NULL, unit = c("country", "county"), year = c("2020", "2019"), matchWith = c("name", "code"), scale = c("500", "20"), subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
data |
a data.frame object with variables to display |
|||||
colID |
character value or columns number indicating the column with unit names or codes |
|||||
unit |
the type of Italian statistical unit |
|||||
year |
year of the analysis |
|||||
matchWith |
the type of id to check:
|
|||||
scale |
the scale of the map |
|||||
subset |
a formula indicating the condition to subset the data, see the Details |
|||||
add |
a formula to add new transformed variables starting from the variables in the |
|||||
new_var_names |
a character value or vector indicating the names of the new variables created in |
|||||
aggregation_fun |
function to use when data are aggregated |
|||||
aggregation_unit |
variable name by which the unit are aggregated |
|||||
aggregation_var |
variable name with value to aggregate |
|||||
facets |
variable(s) name to split the data |
|||||
check.unit.names |
a logical value indicating if the |
|||||
dir |
local directory in which shape files are stored |
|||||
use_cache |
a logical value indicating whether use the cache |
|||||
print |
a logical value indicating whether print the nomatched names |
|||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
|||||
crs |
coordinate reference system. Look at |
The function links (automatically) the id in the data
and the coordinates for the given unit
.
Since the names (or codes) provided in the data
given in input must be checked with the unit
names (or codes) available in the package, the check.unit.names
provides a preliminary check.
subset
provide an expression to subset the data
, using a formula with the logical operators. For example, sub-samples of the data can be selected as follows: ~I("Variable 1" == "condition 1" & "Variable 2" != "condition 2")
or for example, ~I("Variable 1" > "condition 1" | "Variable 2" != "condition 2")
.
An object of class UK
, with data and coordinates to use in functions which perform map.
data("popUK") uk <- UK(data = popUK, unit = "county", matchWith = "code") ### Adding two varaibles uk2 <- UK(data = popUK, unit = "county", matchWith = "code", add = ~I(population/1000) + I(population/100) ) ### Adding to variables and names uk3 <- UK(data = popUK, unit = "county", matchWith = "code", add = ~I(population/1000) + I(population/100), new_var_names = c("ratio1", "ratio2"))
data("popUK") uk <- UK(data = popUK, unit = "county", matchWith = "code") ### Adding two varaibles uk2 <- UK(data = popUK, unit = "county", matchWith = "code", add = ~I(population/1000) + I(population/100) ) ### Adding to variables and names uk3 <- UK(data = popUK, unit = "county", matchWith = "code", add = ~I(population/1000) + I(population/100), new_var_names = c("ratio1", "ratio2"))
US
Creates an object with data and coordinate of class US
for United States of America to use with mapping
functions or available in other R "maps" packages.
US(data, colID = NULL, unit = c("country","region", "division","state", "county", "district", "district_county","urban_area"), year = c("2018"),matchWith = c("name", "id", "number"), scale = c("20", "50", "500"), show_us = TRUE, subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
US(data, colID = NULL, unit = c("country","region", "division","state", "county", "district", "district_county","urban_area"), year = c("2018"),matchWith = c("name", "id", "number"), scale = c("20", "50", "500"), show_us = TRUE, subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
data |
a data.frame object with variables to display |
colID |
character value or column numbers indicating the column with unit names. |
unit |
the type of US statistical unit |
year |
year of the analysis |
matchWith |
the type of id to check if unit is set to "states" |
scale |
the scale of the map |
show_us |
logical value set to TRUE indicating if the entire map is drawn or only the coordinates linked to the input data |
subset |
a formula indicating the condition to subset the data. See the details. |
add |
a formula to add new transformed variables starting from the variables in the |
new_var_names |
a character value or vector indicating the names of the new variables created in |
aggregation_fun |
function to use when data are aggregated |
aggregation_unit |
variable name by which the unit are aggregated |
aggregation_var |
variable name with value to aggregate |
facets |
variable(s) name to split the data |
check.unit.names |
a logical value indicating if the |
dir |
local directory in which shape files are stored |
use_cache |
a logical value indicating whether use the cache |
print |
a logical value indicating whether print the nomatched names |
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
crs |
coordinate reference system. Look at |
The function links (automatically) the id in the data
and the coordinates for the given unit
.
Since the names (or codes) provided in the data
given in input must be checked with the unit
names (or codes) available in the package (as provided by USA Census of Bureau), the check.unit.names
provides a preliminary check.
subset
provide an expression to subset the data
, using a formula with the logical operators. For example, sub-samples of the data can be selected as follows: ~I("Variable 1" == "condition 1" & "Variable 2" != "condition 2")
or for example, ~I("Variable 1" > "condition 1" | "Variable 2" != "condition 2")
.
An object of class US
, with data and coordinates to use in functions which perform map.
data("popUS") us <- US(data = popUS,colID = "id", unit = "state") str(us, 1) us1 <- US(data = popUS, colID = "id", unit = "state", add = ~I(population/100)) str(us1, 1) us2 <- US(data = popUS, colID = "id", unit = "state", add = ~I(population/100), new_var_names = c("population/100")) str(us2, 1)
data("popUS") us <- US(data = popUS,colID = "id", unit = "state") str(us, 1) us1 <- US(data = popUS, colID = "id", unit = "state", add = ~I(population/100)) str(us1, 1) us2 <- US(data = popUS, colID = "id", unit = "state", add = ~I(population/100), new_var_names = c("population/100")) str(us2, 1)
2008 and 2016 Usa presidential election
data("usa_election")
data("usa_election")
A data frame with 51 observations on the following 19 variables.
state_id
a character vector
electoral_votes_obama
a numeric vector
electoral_votes_mccain
a numeric vector
votes_obama
a numeric vector
votes_mccain
a numeric vector
votes_others_08
a numeric vector
total_votes_08
a numeric vector
electoral_votes_trump
a numeric vector
electoral_votes_clinton
a numeric vector
votes_trump
a numeric vector
votes_clinton
a numeric vector
votes_others_16
a numeric vector
total_votes_16
a numeric vector
total_popolation_08
a numeric vector
total_citizen_08
a numeric vector
total_registered_08
a numeric vector
total_popolation_16
a numeric vector
total_citizen_16
a numeric vector
total_registered_16
a numeric vector
https://www.census.gov/topics/public-sector/voting/data.html https://www.fec.gov/introduction-campaign-finance/election-and-voting-information/
data(usa_election) str(usa_election)
data(usa_election) str(usa_election)
WR
Creates an object with data and coordinate of class WR
to use with mapping
function or available in other R "maps" packages.
WR(data, colID = NULL, unit = c("country", "nato", "ocde", "continent", "region", "subregion", "region_wb", "type_income", "type_economy"), matchWith = c("country", "iso2", "iso3", "iso3_eh", "iso3_numeric", "iso3_un", "iso2_wb", "iso3_wb", "name_formal", "name_wb"), res = c("low", "hi"), show_wr = TRUE, subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
WR(data, colID = NULL, unit = c("country", "nato", "ocde", "continent", "region", "subregion", "region_wb", "type_income", "type_economy"), matchWith = c("country", "iso2", "iso3", "iso3_eh", "iso3_numeric", "iso3_un", "iso2_wb", "iso3_wb", "name_formal", "name_wb"), res = c("low", "hi"), show_wr = TRUE, subset = NULL, add = NULL, new_var_names = NULL, aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL, facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE, print = FALSE, use_internet = TRUE, crs = NULL)
data |
a data.frame object with variables to display |
||||||||||||||||||||
colID |
character value or columns number indicating the column with unit names |
||||||||||||||||||||
unit |
the type of world statistical unit |
||||||||||||||||||||
matchWith |
the type of id to check:
|
||||||||||||||||||||
res |
map resolution |
||||||||||||||||||||
show_wr |
logical value set to TRUE indicating if the entire map is drawn or only the coordinates linked to the input data |
||||||||||||||||||||
subset |
a formula indicating the condition to subset the data, see the Details |
||||||||||||||||||||
add |
a formula to add new transformed variables starting from the variables in the |
||||||||||||||||||||
new_var_names |
a character value or vector indicating the names of the new variables created in |
||||||||||||||||||||
aggregation_fun |
function to use when data are aggregated |
||||||||||||||||||||
aggregation_unit |
variable name by which the unit are aggregated |
||||||||||||||||||||
aggregation_var |
variable name with value to aggregate |
||||||||||||||||||||
facets |
variable(s) name to split the data |
||||||||||||||||||||
check.unit.names |
a logical value indicating if the |
||||||||||||||||||||
dir |
local directory in which shape files are stored |
||||||||||||||||||||
use_cache |
a logical value indicating whether use the cache |
||||||||||||||||||||
print |
a logical value indicating whether print the nomatched names |
||||||||||||||||||||
use_internet |
a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If |
||||||||||||||||||||
crs |
coordinate reference system. Look at |
The function links (automatically) the id in the data
and the coordinates for the given unit
.
Since the names (or codes) provided in the data
given in input must be checked with the unit
names (or codes) available in the package, the check.unit.names
provides a preliminary check.
subset
provide an expression to subset the data
, using a formula with the logical operators. For example, sub-samples of the data can be selected as follows: ~I("Variable 1" == "condition 1" & "Variable 2" != "condition 2")
or for example, ~I("Variable 1" > "condition 1" | "Variable 2" != "condition 2")
.
An object of class WR
, with data and coordinates to use in functions which perform map.
data("popWR") wr <- WR(data = popWR, colID = "country_code", matchWith = "iso3_eh", res = "low") str(wr, 1) wr1 <- WR(data = popWR, colID = "country_code", matchWith = "iso3_eh", res = "low", add = ~I(male/total) + I(female/total)) str(wr1) wr2 <- WR(data = popWR, colID = "country_code", matchWith = "iso3_eh", res = "low", add = ~I(male/total) + I(female/total), new_var_names = c("Per_Male", "Per_Female")) str(wr2)
data("popWR") wr <- WR(data = popWR, colID = "country_code", matchWith = "iso3_eh", res = "low") str(wr, 1) wr1 <- WR(data = popWR, colID = "country_code", matchWith = "iso3_eh", res = "low", add = ~I(male/total) + I(female/total)) str(wr1) wr2 <- WR(data = popWR, colID = "country_code", matchWith = "iso3_eh", res = "low", add = ~I(male/total) + I(female/total), new_var_names = c("Per_Male", "Per_Female")) str(wr2)