---
title: "mapping World"
output: 
  rmarkdown::html_vignette:
    keep_md: true 
    toc: true
vignette: >
  %\VignetteIndexEntry{mapping World}
  %\VignetteEngine{knitr::rmarkdown}
  %\usepackage[utf8]{inputenc}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,
                      collapse = TRUE, 
                      fig.width = 7, fig.height = 4, fig.align = "center",
                      message = FALSE, warning = FALSE)
```



The CRAN version can be loaded as follows:
```{r, message = FALSE}
library('mapping')
```

or the development version from GitHub:

```{r, message = FALSE, eval=FALSE}
remotes::install_github('serafinialessio/mapping')
```


The worldwide geographical aggregates nomenclature  are the following:

| Function argument | Aggregates | Level | 
------------|------------| -------------|
| "continent" | Continents | level 0 |
| "regions" | World regions | level 1 |
| "subregion" | World subregions | level 2 |
| "country" | Countries | level 3 |

where **level 0** is the largest unit (continent), and **level 4** the smallest unit.

Countries can be subdivided in other aggregates, based on type of economics or development

| Function argument | Type |  
------------|------------| 
| "type" | Classification based on the type of political entity | 
| "type_economy" | Classification based on the type of development | 
| "type_income" | Classification based on the type of income | 

and based on the belonging to some international organisation

| Function argument | Type |  
------------|------------| 
| "nato" | If is a NATO country | 
| "ocde" | If is a ICDE country | 


```{r, echo=FALSE}
DiagrammeR::grViz("
  digraph graph2 {
  
  graph [layout = dot, rankdir = LR]
  
  # node definitions with substituted label text
  node [shape = oval]
  a [label = 'continent']
  b [label = 'regions']
  c [label = 'subregion']
  d [label = 'country']

  
  d -> c -> b -> a
  }
  
  ",height = 100)
```


`Level` may have names expressed in different way. The package provides:

|  Names | Code |  
------------|------------| 
| Country names | `country` | 
| iso2 code | `iso2` | 
| iso3 code | `iso3` | 
| iso3 numeric | `iso3_numeric` |
| iso3 United Nations  | `iso3_un` |
| iso2 World Bank  | `iso2_wb` |
| Formal name  | `name_formal` |
| World Bank name  | `name_wb` |

This can be specified in `matchWith` argument, depending on the **ids** format in the input data. 


```{r}
wr_continent <- loadCoordWR(unit = "continent", res = "hi")
mappingWR(wr_continent)
```

```{r}
wr_regions <- loadCoordWR(unit = "region", res = "hi")
mappingWR(wr_regions)
```


```{r}
wr_subregion <- loadCoordWR(unit = "subregion", res = "hi")
mappingWR(wr_subregion)
```

```{r}
wr_country <- loadCoordWR(unit = "country", res = "hi")
mappingWR(wr_country)
```


```{r}
wr_nato <- loadCoordWR(unit = "nato", res = "hi")
mappingWR(wr_nato)
```



```{r}
wr_ocde <- loadCoordWR(unit = "ocde", res = "hi")
mappingWR(wr_ocde)
```

