An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

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

![](http://img.shields.io/badge/cool-useless-green.svg)

`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()
```