Package 'WorldMapR'

Title: 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.
Authors: Luigi Annicchiarico [cre, aut]
Maintainer: Luigi Annicchiarico <[email protected]>
License: GPL-3
Version: 1.0.1
Built: 2024-11-21 17:21:25 UTC
Source: https://github.com/luigi-annic/worldmapr

Help Index


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 TRUE (default), countries that do not have a ISO 3166 code are excluded from the table.

countries.list

List of the ISO 3166-1 alpha-2 codes of countries that are to be included. By default it is set to NULL and all countries are included.

Value

an object of class data.frame and sf.

Examples

geometries_data(countries.list = c("IT", "FR", "US"))

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),
  annote = FALSE,
  div = 1,
  palette_option = "D",
  na_colour = "grey80",
  transform_limits = 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 CountryName. One of isoa2 (default, standing for ISO 3166-1 alpha-2 code), isoa3, or name.

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 c(-180, 180) (whole world with crs as EPSG::4326).

latitude

Latitude limits. Default is c(-90, 90) (whole world with crs as EPSG::4326).

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.

annote

Do you want to plot country labels (ISO 3166-1 alpha-2 code) on the map? Default is set to FALSE.

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".

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

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),
  Categories = levels(factor(map_df$MapFiller)),
  na.as.category = TRUE,
  annote = FALSE,
  div = 1,
  palette_option = "D",
  na_colour = "grey80",
  transform_limits = 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 CountryName. One of isoa2 (default, standing for ISO 3166-1 alpha-2 code), isoa3, or name.

longitude

Longitude limits. Default is c(-180, 180) (whole world with crs as EPSG::4326).

latitude

Latitude limits. Default is c(-90, 90) (whole world with crs as EPSG::4326).

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.

Categories

categories labels to be plotted in the legend.

na.as.category

Treat NA as a separate category? If 'TRUE, NA will also appear in the legend as one of the categories.

annote

Do you want to plot country labels (ISO 3166-1 alpha-2 code) on the map? Default is set to FALSE.

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

Value

a map

Examples

data(testdata1b)
worldplotCat(data = testdata1b,
             div = 1,
             ColName = "VCat",
             CountryName = "Cshort",
             CountryNameType = "isoa2",
             annote = FALSE)