Type: | Package |
Title: | Worldwide or Coordinates-Based Heat Maps |
Version: | 1.2.0 |
Description: | Easily plot heat maps of the world, based on continuous or categorical data. Country labels can also be added to the map. |
License: | GPL-3 |
URL: | https://github.com/Luigi-Annic/WorldMapR/ |
BugReports: | https://github.com/Luigi-Annic/WorldMapR/issues |
Encoding: | UTF-8 |
Depends: | R (≥ 4.3.0) |
Imports: | ggplot2 (≥ 3.4.4), dplyr (≥ 1.1.4), sf (≥ 1.0-14), countrycode (≥ 1.5.0), utils (≥ 4.3.0), ggfx (≥ 1.0.1) |
LazyData: | true |
RoxygenNote: | 7.3.2 |
Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0), |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2025-03-21 10:14:44 UTC; luigi.annicchiaric00 |
Author: | Luigi Annicchiarico [cre, aut] |
Maintainer: | Luigi Annicchiarico <luigi.annic@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-03-21 10:30:02 UTC |
WorldMapR: Worldwide or Coordinates-Based Heat Maps
Description
Easily plot heat maps of the world, based on continuous or categorical data. Country labels can also be added to the map.
Author(s)
Maintainer: Luigi Annicchiarico luigi.annic@gmail.com
See Also
Useful links:
Report bugs at https://github.com/Luigi-Annic/WorldMapR/issues
countrycoord_data
Description
This function generates a data frame with information about the coordinates of the central point for each country of interest. You can choose whether to keep all the countries or only a subset.
Usage
countrycoord_data(
countries.list = NULL,
crs = 4326,
UK_as_GB = TRUE,
exclude.iso.na = TRUE
)
Arguments
countries.list |
List of the ISO 3166-1 alpha-2 codes of countries that are to be included. By default it is set to |
crs |
Coordinate reference system (EPSG). By default the value is 4326, which corresponds to EPSG::4326 (WGS84) |
UK_as_GB |
Which do you prefer between UK and GB as the code for the United Kingdom? If FALSE, GB is returned in the output data.frame. If TRUE (default), UK is returned. |
exclude.iso.na |
if |
Value
an object of class data.frame
Examples
countrycoord_data(countries.list = c("IT", "FR", "SE"), crs = 3035)
countrycoord_data(countries.list = c("IT", "FR", "SE"), crs = 3035)
countrycoord_data(countries.list = c("IT", "FR", "SE", "GB"), crs = 3035, UK_as_GB = TRUE)
countrycoord_data(countries.list = c("IT", "FR", "SE", "GB"), crs = 3035, UK_as_GB = FALSE)
geometries_data
Description
This function generates a data frame with information about geometries and centroid coordinates of countries. You can choose whether to keep all the countries or only a subset.
Usage
geometries_data(exclude.iso.na = TRUE, countries.list = NULL)
Arguments
exclude.iso.na |
if |
countries.list |
List of the ISO 3166-1 alpha-2 codes of countries that are to be included. By default it is set to |
Value
an object of class data.frame
and sf
.
Examples
geometries_data(countries.list = c("IT", "FR", "US"))
Initial dataset with geometries for each country
Description
This data set contains information about name, iso_a2 code and geometry for 242 countries.
Usage
data(map_df0)
Format
An object of class data.frame
Examples
data(map_df0)
head(map_df0)
Simulated data set 1
Description
Data from a random simulation with continuous data.
Usage
data(testdata1)
Format
An object of class data.frame
Examples
data(testdata1)
head(testdata1)
Simulated data set 1b
Description
Data from a random simulation with continuous and categorical data.
Usage
data(testdata1b)
Format
An object of class data.frame
Examples
data(testdata1b)
head(testdata1b)
Simulated data set 1c
Description
Data from a random simulation with continuous and categorical data. This data set contains information about 237 countries (countries without unique ISO 3166 code are excluded).
Usage
data(testdata1c)
Format
An object of class data.frame
Examples
data(testdata1c)
head(testdata1c)
worldplot
Description
Plot a world heat map based on a continuous variable.
Usage
worldplot(
data,
ColName,
CountryName,
CountryNameType = "isoa2",
rangeVal,
longitude = c(-180, 180),
latitude = c(-90, 90),
crs = 4326,
title = "",
legendTitle = as.character(ColName),
legend.position = "right",
annote = FALSE,
div = 1,
palette_option = "D",
label.color = "white",
label.size = 2,
na_colour = "grey80",
transform_limits = TRUE,
shadows = TRUE,
UK_as_GB = TRUE
)
Arguments
data |
Data set containing the list of nations and the variable that we want to plot. |
ColName |
Character variable with the name of the variable of interest. |
CountryName |
Character variable with the name of the country names column. |
CountryNameType |
Character variable with the coding for |
rangeVal |
Limit values (minimum and maximum) that are to be defined for the map. If not specified, the minimum and maximum are taken, and a message is displayed. |
longitude |
Longitude limits. Default is |
latitude |
Latitude limits. Default is |
crs |
Coordinate reference system (EPSG). By default the value is 4326, which corresponds to EPSG::4326 (WGS84) |
title |
Title of the plot. Default is no title. |
legendTitle |
Title of the legend. Default is the name of the filling variable. |
legend.position |
Position of the legend. If set to "none", no legend is displayed |
annote |
Do you want to plot country labels (ISO 3166-1 alpha-2 code) on the map? Default is set to |
div |
Parameter for modifying the elements dimensions in the map. Usually, it does not need to be modified. Default value is 1. |
palette_option |
Character string indicating the palette to be used. Available options range between "A" and "H". |
label.color |
Color of the labels if annote = TRUE. Default is white |
label.size |
Size of the labels if annote = TRUE |
na_colour |
The colour to be used for countries with missing information. Default is grey80 |
transform_limits |
Only if crs is specified and different from 4326. If TRUE (the default) the program expects to receive values of longitude and latitude as in EPSG 4326, (i.e., within -180, +180 for longitude and within -90, +90 for latitude) and automatically updates to the new crs. Set to FALSE if you want to define longitude and latitude limits based on the new crs |
shadows |
If TRUE, add shadows to the country labels (only if annote = TRUE) |
UK_as_GB |
Argument passed to countrycoord_data if annote is set to TRUE. Do you want to translate the GB isoa2 code to UK? If FALSE, GB is returned in the output data.frame. If TRUE (default), UK is returned. |
Value
a map
Examples
data(testdata1b)
worldplot(data = testdata1b,
div = 1,
ColName = "VNum",
CountryName = "Cshort",
CountryNameType = "isoa2",
rangeVal = c(0,50),
annote = FALSE)
worldplotCat
Description
Plot a world heat map based on a categorical variable.
Usage
worldplotCat(
data,
ColName,
CountryName,
CountryNameType = "isoa2",
longitude = c(-180, 180),
latitude = c(-90, 90),
crs = 4326,
title = "",
legendTitle = as.character(ColName),
legend.position = "right",
Categories = levels(factor(map_df$MapFiller)),
na.as.category = TRUE,
label.color = "white",
label.size = 2,
annote = FALSE,
div = 1,
palette_option = "D",
na_colour = "grey80",
transform_limits = TRUE,
shadows = TRUE,
UK_as_GB = TRUE
)
Arguments
data |
Data set containing the list of nations and the variable that we want to plot. |
ColName |
Character variable with the name of the variable of interest. |
CountryName |
Character variable with the name of the country names column. |
CountryNameType |
Character variable with the coding for |
longitude |
Longitude limits. Default is |
latitude |
Latitude limits. Default is |
crs |
Coordinate reference system (EPSG). By default the value is 4326, which corresponds to EPSG::4326 (WGS84) |
title |
Title of the plot. Default is no title. |
legendTitle |
Title of the legend. Default is the name of the filling variable. |
legend.position |
Position of the legend. If set to "none", no legend is displayed |
Categories |
categories labels to be plotted in the legend. |
na.as.category |
Treat |
label.color |
Color of the labels if annote = TRUE. Default is white |
label.size |
Size of the labels if annote = TRUE |
annote |
Do you want to plot country labels (ISO 3166-1 alpha-2 code) on the map? Default is set to |
div |
Parameter for modifying the elements dimensions in the map. Usually, it does not need to be modified. Default value is 1. |
palette_option |
Character string indicating the palette to be used. Available options range between "A" and "H". You can also enter a string with a colour for each category |
na_colour |
The colour to be used for countries with missing information. Default is grey80 |
transform_limits |
Only if crs is specified and different from 4326. If TRUE (the default) the program expects to receive values of longitude and latitude as in EPSG 4326, (i.e., within -180, +180 for longitude and within -90, +90 for latitude) and automatically updates to the new crs. Set to FALSE if you want to define longitude and latitude limits based on the new crs |
shadows |
If TRUE, add shadows to the country labels (only if annote = TRUE) |
UK_as_GB |
Argument passed to countrycoord_data if annote is set to TRUE. Do you want to translate the GB isoa2 code to UK? If FALSE, GB is returned in the output data.frame. If TRUE (default), UK is returned. |
Value
a map
Examples
data(testdata1b)
worldplotCat(data = testdata1b,
div = 1,
ColName = "VCat",
CountryName = "Cshort",
CountryNameType = "isoa2",
annote = FALSE)