Skip to content
Snippets Groups Projects
Commit dde29098 authored by Jenny Bryan's avatar Jenny Bryan
Browse files

Be careful about preserving the int type of iso_num

Fixes #29
parent 45539d01
No related branches found
No related tags found
No related merge requests found
......@@ -186,7 +186,7 @@ gapminder %>%
#> into character vector
#> # A tibble: 3 x 4
#> country continent iso_alpha iso_num
#> <chr> <fct> <chr> <dbl>
#> <chr> <fct> <chr> <int>
#> 1 Kenya Africa KEN 404
#> 2 Peru Americas PER 604
#> 3 Syria Asia SYR 760
......
......@@ -27,18 +27,18 @@ country_codes %>%
## Add it back to reflect reality during the years spanned by gapminder
netherlands_antilles <- country_codes$country == "Netherlands Antilles"
country_codes$iso_alpha[netherlands_antilles] <- "ANT"
country_codes$iso_num[netherlands_antilles] <- 530
country_codes$iso_num[netherlands_antilles] <- 530L
## Sudan's numeric country code changed when South Sudan split off in 2011
## apparently, countrycode v1.0.0 now reflects that
## Add it back to reflect reality during the years spanned by gapminder
sudan <- country_codes$country == "Sudan"
country_codes$iso_num[sudan] <- 736
country_codes$iso_num[sudan] <- 736L
## manually correct codes for North Korea (Korea, Dem. Rep.)
north_korea <- country_codes$country == "Korea, Dem. Rep."
country_codes$iso_alpha[north_korea] <- "PRK"
country_codes$iso_num[north_korea] <- 408
country_codes$iso_num[north_korea] <- 408L
save(
country_codes,
......
10\_iso-codes.R
================
jenny
2018-09-24
2019-03-06
``` r
library(countrycode)
......@@ -15,14 +15,14 @@ library(gapminder)
library(tidyverse)
```
## ── Attaching packages ───────────────────────────────────────── tidyverse 1.2.1 ──
## ── Attaching packages ───────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.0.0 ✔ purrr 0.2.5
## ✔ tibble 1.4.99.9004 ✔ dplyr 0.7.99.9000
## ✔ tidyr 0.8.1 ✔ stringr 1.3.1
## ✔ readr 1.2.0 ✔ forcats 0.3.0
## ✔ ggplot2 3.1.0 ✔ purrr 0.3.0
## ✔ tibble 2.0.1.9001 ✔ dplyr 0.8.0.9000
## ✔ tidyr 0.8.3.9000 ✔ stringr 1.4.0
## ✔ readr 1.3.1 ✔ forcats 0.4.0
## ── Conflicts ──────────────────────────────────────────── tidyverse_conflicts() ──
## ── Conflicts ──────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
......@@ -36,7 +36,7 @@ conflicted::conflict_prefer("filter", "dplyr")
packageVersion("countrycode")
```
## [1] '1.0.0'
## [1] '1.1.0'
``` r
country_codes <- tibble(
......@@ -67,18 +67,18 @@ country_codes %>%
## Add it back to reflect reality during the years spanned by gapminder
netherlands_antilles <- country_codes$country == "Netherlands Antilles"
country_codes$iso_alpha[netherlands_antilles] <- "ANT"
country_codes$iso_num[netherlands_antilles] <- 530
country_codes$iso_num[netherlands_antilles] <- 530L
## Sudan's numeric country code changed when South Sudan split off in 2011
## apparently, countrycode v1.0.0 now reflects that
## Add it back to reflect reality during the years spanned by gapminder
sudan <- country_codes$country == "Sudan"
country_codes$iso_num[sudan] <- 736
country_codes$iso_num[sudan] <- 736L
## manually correct codes for North Korea (Korea, Dem. Rep.)
north_korea <- country_codes$country == "Korea, Dem. Rep."
country_codes$iso_alpha[north_korea] <- "PRK"
country_codes$iso_num[north_korea] <- 408
country_codes$iso_num[north_korea] <- 408L
save(
country_codes,
......
No preview for this file type
man/figures/README-demo-country-colors-base-1.png

129 KiB | W: | H:

man/figures/README-demo-country-colors-base-1.png

191 KiB | W: | H:

man/figures/README-demo-country-colors-base-1.png
man/figures/README-demo-country-colors-base-1.png
man/figures/README-demo-country-colors-base-1.png
man/figures/README-demo-country-colors-base-1.png
  • 2-up
  • Swipe
  • Onion skin
man/figures/README-demo-country-colors-ggplot2-1.png

464 KiB | W: | H:

man/figures/README-demo-country-colors-ggplot2-1.png

607 KiB | W: | H:

man/figures/README-demo-country-colors-ggplot2-1.png
man/figures/README-demo-country-colors-ggplot2-1.png
man/figures/README-demo-country-colors-ggplot2-1.png
man/figures/README-demo-country-colors-ggplot2-1.png
  • 2-up
  • Swipe
  • Onion skin
man/figures/README-test-drive-1.png

438 KiB | W: | H:

man/figures/README-test-drive-1.png

442 KiB | W: | H:

man/figures/README-test-drive-1.png
man/figures/README-test-drive-1.png
man/figures/README-test-drive-1.png
man/figures/README-test-drive-1.png
  • 2-up
  • Swipe
  • Onion skin
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment