https://github.com/coolbutuseless/flagon
Flags of the World
https://github.com/coolbutuseless/flagon
Last synced: 4 months ago
JSON representation
Flags of the World
- Host: GitHub
- URL: https://github.com/coolbutuseless/flagon
- Owner: coolbutuseless
- License: mit
- Created: 2020-04-01T10:31:59.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-03T22:55:09.000Z (over 5 years ago)
- Last Synced: 2025-04-09T02:41:53.340Z (6 months ago)
- Language: R
- Size: 2.91 MB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - coolbutuseless/flagon - Flags of the World (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)suppressPackageStartupMessages({
library(dplyr)
library(ggplot2)
library(flagon)
library(magick)
})```
# flagon

`flagon` provides PNG and SVG images of the flags of the world, indexed by
their [2-letter ISO-3166 country codes](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes).The flags are sourced from [https://github.com/hjnilsson/country-flags](https://github.com/hjnilsson/country-flags), and are the public domain flag images from wikipedia.
All PNG flags are 1000px in width.
## Installation
You can install from [GitHub](https://github.com/coolbutuseless/flagon) with:
``` r
# install.packages("remotes")
remotes::install_github("coolbutuseless/flagon")
```## Usage: Retrieving filenames
```{r}
library(flagon)ccodes <- c('au', 'dk') # Australia and Germany
flagon::flags(ccodes)
flagon::flags(ccodes, 'svg')
```## Using with `magick`
```{r flag_example, out.width="50%"}
magick::image_read(flagon::flags('no'))
```## That's it
That's all this package does.
There's also a table of country codes (`flagon::country_codes`) along with some
image information. The first rows are shown below:```{r echo = FALSE}
flagon::country_codes %>%
head %>%
knitr::kable()
```The aspect ratios for flags varies widely.
```{r aspect_ratio, echo = FALSE, fig.width = 4, fig.height = 3, out.width="50%"}
ggplot(flagon::country_codes) +
geom_histogram(aes(aspect_ratio), bins = 30) +
theme_bw()
```The two outliers are Nepal (aspect ratio = 0.82) and Qatar (aspect ratio = 4.17)
```{r outliers}
flagon::country_codes %>%
filter(aspect_ratio %in% range(aspect_ratio)) %>%
pull(ccode) %>%
flagon::flags() %>%
magick::image_read() %>%
magick::image_montage()
```