Title: | Countries of the World |
---|---|
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. |
Authors: | Yves Croissant [aut, cre] |
Maintainer: | Yves Croissant <[email protected]> |
License: | GPL (>=2) |
Version: | 0.1-2 |
Built: | 2024-11-20 13:40:25 UTC |
Source: | https://github.com/ycroissant/necountries |
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
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 )
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 )
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, |
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"
countries("Western Europe")
countries("Western Europe")
dplyr
's verbscountries
' objects inherits from sf
, when a verb of dlpyr
is
used, the returned object is of class sf
; these methods return a
countries
object.
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 )
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 )
x , y , by , copy , suffix , keep
|
see |
side |
for the |
.data |
see |
... |
further arguments |
for the select
and the left_join
method, a data frame
sf
to optimize the position of labelsDisplaying labels on a map is complicated because of serious
overlapping problems. Labels for different kinds of entities can be
put in a unique sf
## S3 method for class 'countries' labels(object, ..., var)
## S3 method for class 'countries' labels(object, ..., var)
object |
a |
... |
further arguments (currently unused), |
var |
a character vector indicating the entities that should
be labeleld, it can be |
a sf
containing:
name
the names of the entities,
type
the type of the entity (either country
, capitaland
towns')
point
the coordinate of the points (obtained using
st_point_on_surface
for countries)
A sf
containing 299 countries (in a large sense), either the main
parts of sovereign countries, parts or dependencies
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
A sf
containing 7342 cities
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 point sfc
containing the coordinates of the city
countries
objectsAs 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
## S3 method for class 'countries' plot( x, ..., labels = NULL, fill = NULL, capital = NULL, centroid = NULL, towns = NULL, bks = NULL, n = 6, size = c(1, 10), shape = c(15, 16), style = NULL, palette = NULL, bw = FALSE, oceans = "lightblue", background = "lightgrey" )
## S3 method for class 'countries' plot( x, ..., labels = NULL, fill = NULL, capital = NULL, centroid = NULL, towns = NULL, bks = NULL, n = 6, size = c(1, 10), shape = c(15, 16), style = NULL, palette = NULL, bw = FALSE, oceans = "lightblue", background = "lightgrey" )
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 , towns
|
a variable associated with the shape or the size of points; for towns, the only available variable is "pop", it town is a boolean fixed points are used with a specific shape for capitals if shape is of length 2 |
bks |
an optional vector of breaks in order to use a continuous variable for fill |
n |
the number of class (passed to |
size |
either an integer for a fixed size or a couple of integer to define the range of the sizes of the points |
shape |
either one integer for a fixed shape or a couple of integer to get a specific shape for capitals |
style |
the style (passed to |
palette |
the palette (selected in |
bw |
a boolean, if |
oceans , background
|
a character indicating the color for the oceans and the background |
a gg
object.
we <- countries("Western Europe") plot(we)
we <- countries("Western Europe") plot(we)
a cross-section of 52 countries from 2000
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
Nathan Nunn's website https://nathannunn.arts.ubc.ca/
Adummy A (2024). “Not avalable.” Failed to insert reference with key = NUNN:08 from package = 'necountries'. Possible cause — missing REFERENCES.bib in package 'necountries' or 'necountries' not installed..
a cross-section of 91 countries from 1995
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
JAE data archive
Adummy A (2024). “Not avalable.” Failed to insert reference with key = ERTU:KOCH:07 from package = 'necountries'. Possible cause — missing REFERENCES.bib in package 'necountries' or 'necountries' not installed..
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
towns(x, size = NULL, capital = FALSE, crs = NULL, shift = FALSE)
towns(x, size = NULL, capital = FALSE, crs = NULL, shift = FALSE)
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 |
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 point sfc
containing the coordinates of the city
we <- countries("Western Europe") towns(we, size = 1E06, capital = TRUE)
we <- countries("Western Europe") towns(we, size = 1E06, capital = TRUE)
utm
returns the relevant UTM crs (in the 'proj4string' form)
utm(x)
utm(x)
x |
either an integer (from 1L to 60L) or a 'sf |
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
a character string
a character (a crs i, the 'proj4string' format)
we <- countries("Western Europe") utm(we) utm(32L)
we <- countries("Western Europe") utm(we) utm(32L)