Version: | 0.1-1 |
Date: | 2024-11-14 |
Title: | Countries of the World |
Depends: | R (≥ 4.0.0) |
Imports: | Rdpack, tibble, ggplot2, sf, dplyr, ggrepel, rlang, classInt, stringr, magrittr, stringi |
Description: | Based on Natural Earth https://www.naturalearthdata.com/, a subset of countries can easily be selected with their administrative boundaries, joined with an external data frame and plotted as a thematic map. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
URL: | https://www.R-project.org |
RoxygenNote: | 7.3.1 |
Author: | Yves Croissant |
Maintainer: | Yves Croissant <yves.croissant@univ-reunion.fr> |
LazyData: | true |
NeedsCompilation: | no |
Suggests: | knitr, tidyr, purrr, quarto |
VignetteBuilder: | quarto |
RdMacros: | Rdpack |
Packaged: | 2024-11-14 12:12:10 UTC; yves |
Repository: | CRAN |
Date/Publication: | 2024-11-15 09:00:10 UTC |
Countries from naturalearth
Description
Select a set of countries; talking about countries, we mean either sovereign countries, parts of countries and dependencies, each of these cathegories being on each own row. A single or a set of countries can be obtained by indicating a set of names of, either countries, regions or subregions
Usage
countries(
name = NA,
part = FALSE,
dependency = FALSE,
indeterminate = FALSE,
exclude = NULL,
include = NULL,
utm = FALSE,
crs = NULL,
towns = FALSE,
capital = FALSE,
lang = NULL,
extend = 1,
shift = FALSE,
coastlines = TRUE
)
Arguments
name |
a character vector that contains one or several countries, regions or subregions (mixing the two of the three cathegories will result as an error), |
part |
should the parts of the countries be included (eg Azsores for Portugal or Alaska for the United States of America), |
dependency |
should the dependencies of the countries be included (eg Greenland and the Faroe Islands for Denmark), |
indeterminate |
should the indeterminate territories be included, |
exclude |
an optional set of countries that should be excluded from the request, |
include |
an optional set of countries that should be included |
utm |
if |
crs |
a CRS |
towns |
if |
capital |
if |
lang |
the language for countries and towns, one of |
extend |
a number >= 1, extend the bounding box so that the background is larger than the initial bounding box and can be transformed correctly if utm transformation is required |
shift |
a boolean, if |
coastlines |
a boolean, |
Value
an object of class countries
which inherits from sf
with the following columns:
-
id
the two letters identifier of the country, -
type
either"main"
(the main part of a sovereign country, the whole country for most of them) -country
the name of the entity, -
sovereign
the sovereign country the entity belongs to, -
capital
the name of the capital of the country (NA for parts and dependencies) -subregion
the name of the subregion (United Nations' definition) -
pop
the population of the entity, -
gdp
currently undocumented -
wbreg
the name of the region (World Bank's definition) -
region
the name of the region (United Nations' definition) Two attributes"type"
and"towns"
Examples
countries("Western Europe")
Methods for dplyr
's verbs
Description
countries
' objects inherits from sf
, when a verb of dlpyr
is
used, the returned object is of class sf
; these methods return a
countries
object.
Usage
check_join(x, y, by = NULL, side = c("right", "both", "left"))
## S3 method for class 'countries'
select(.data, ...)
## S3 method for class 'countries'
left_join(
x,
y,
by = NULL,
copy = FALSE,
suffix = c(".x", ".y"),
...,
keep = NULL
)
Arguments
x , y , by , copy , suffix , keep |
see |
side |
for the |
.data |
see |
... |
further arguments |
Value
for the select
and the left_join
method, a data frame
Compute a unique sf
to optimize the position of labels
Description
Displaying labels on a map is complicated because of serious
overlapping problems. Labels for different kinds of entities can be
put in a unique sf
Usage
## S3 method for class 'countries'
labels(object, ..., var)
Arguments
object |
a |
... |
further arguments (currently unused), |
var |
a character vector indicating the entities that should
be labeleld, it can be |
Value
a sf
containing:
-
name
the names of the entities, -
type
the type of the entity (eithercountry
, capitaland
towns') -
point
the coordinate of the points (obtained usingst_point_on_surface
for countries)
Countries of naturalearth
Description
A sf
containing 299 countries (in a large sense), either the main
parts of sovereign countries, parts or dependencies
Format
a sf
containing
-
iso2
: two letters identifier of the country, -
iso3
: two letters identifier of the country, -
type
: either"main"
(the main part of a sovereign country, the whole country for most of them),"part"
,"dependency"
or"indeterminate"
-
country
: the name of the entity, -
sovereign
: the sovereign country the entity belongs to, -
capital
: the name of the capital of the country (NA for parts and dependencies) -
status
: United Nations' status -
en
,fr
,de
,es
,it
: the name of the country in different languages -
region
: the name of the region (United Nations' definition) -
subregion
: the name of the subregion (United Nations' definition) -
wbregion
: the name of the region (World Bank's definition) -
pop
: the population of the entity, -
gdp
: currently undocumented -
economy
: economic group -
income
: income groupe -
polygon
a geometry column containing the administrative borders -
point
a geometry column containing the point coordinate of the capital
Populated places of naturalearth
Description
A sf
containing 7342 cities
Format
a sf
containing
-
id
: the id of the country, -
name
: the name of the city, -
capital
: a boolean,TRUE
for a capital -
pop
: the population of the city, -
point
: a pointsfc
containing the coordinates of the city
Basic plot function for countries
objects
Description
As the plot
method of sf
, this function is intended to obtain
quickly a map for a set of countries. Countries' boundaries are
represented and filling can be used, some cities can also be
represented and labels can be added. ggplot
is used and should be
used directly when more enhanced maps are required
Usage
## S3 method for class 'countries'
plot(
x,
...,
labels = NULL,
fill = NULL,
capital = NULL,
centroid = NULL,
bks = NULL,
n = 6,
style = NULL,
palette = NULL,
bw = FALSE
)
Arguments
x |
a |
... |
further arguments (currently unused) |
labels |
a character vector containing the variables that
should be labeled: |
fill |
a variable use to fill countries' polygons |
capital , centroid |
a variable associated with the shape or the size of points |
bks |
an optional vector of breaks in order to use a continuous variable for fill |
n |
the number of class (passed to |
style |
the style (passed to |
palette |
the palette (selected in |
bw |
a boolean, if |
Value
a gg
object.
Examples
we <- countries("Western Europe")
plot(we)
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
Slave trade and economic development
Description
a cross-section of 52 countries from 2000
Format
a tibble containing:
country: the country name
region: one of 'north', 'east', 'central', 'south', 'west'
disteq: distance from equator
longitude: longitude
area: area in thousands of km squared
pop: average population during the slave trade period
coastline: log coastlines divided by the country area
island: island indicator
islam: percent islamic
colony: previous colonizator, one of 'none', 'uk', 'france', 'portugal', 'belgium', 'spain', 'germany', 'italy'
legor: legal origin, one of 'french' and 'british'
gdp: log real gdp per capita in 2000
slaves: number of slaves
slavesarea: number of slaves divided by the country area
humidmax: average maximum humidity
rainmin: lowest month rainfall
lowtemp: average minimum temperature
gold: log gold production per inhabitant
oil: log oil production per inhabitant
diamond: log diamonds production per inhabitant
atlantic: distance to the atlantic ocean
indian: distance to the indian ocean
redsea: distance to the red sea
sahara: distance to sahara
Source
Nathan Nunn's website https://nathannunn.arts.ubc.ca/
References
Nunn N (2008). “The Long-Term Effects of Africa's Slave Trades.” The Quarterly Journal of Economics, 123(1), 139–176. ISSN 00335533, 15314650, https://www.jstor.org/stable/25098896.
Solow's growth model with spatial correlation
Description
a cross-section of 91 countries from 1995
Format
a tibble containing:
name: the name of the country
code: the id of the country
gdp60: per capita gdp in 1960
gdp95: per capita gdp in 1995
saving: saving rate
labgwth: growth rate of the labor force
Source
JAE data archive
References
Ertur C, Koch W (2007). “Growth, technological interdependence and spatial externalities: theory and evidence.” Journal of Applied Econometrics, 22(6), 1033-1062. doi:10.1002/jae.963, https://onlinelibrary.wiley.com/doi/pdf/10.1002/jae.963, https://onlinelibrary.wiley.com/doi/abs/10.1002/jae.963.
Populated places from naturalearth
Description
Select a set of cities; the set can be defined using the id of the country, the fact that it is a capital and the size
Usage
towns(x, size = NULL, capital = FALSE, crs = NULL, shift = FALSE)
Arguments
x |
a |
size |
the minimum size of the cities that have to be
retrieved (the default value is |
capital |
if |
crs |
an optional crs which is passed to |
shift |
a boolean, if |
Value
a sf
containing five columns:
-
iso2
: the id of the country, -
iso3
: the id of the country, -
name
: the name of the city, -
capital
: a boolean,TRUE
for a capital -
pop
: the population of the city, -
point
: a pointsfc
containing the coordinates of the city
Examples
we <- countries("Western Europe")
towns(we, size = 1E06, capital = TRUE)
Universal Transverse Mercator projection
Description
utm
returns the relevant UTM crs (in the 'proj4string' form)
Usage
utm(x)
Arguments
x |
either an integer (from 1L to 60L) or a 'sf |
Details
There is one utm projections for each of the 60 zones that divide
the world. The zone can be indicated as an integer (ie 12L, and not
12) or can be computed from a sf
object
Value
a character string
a character (a crs i, the 'proj4string' format)
Examples
we <- countries("Western Europe")
utm(we)
utm(32L)