forked from ellisp/ggflags
-
Notifications
You must be signed in to change notification settings - Fork 15
/
README.Rmd
55 lines (40 loc) · 1.2 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
## ggflags: Plot flags of the world in ggplot2
A flag geom for ggplot2. Uses circular SVG flags.
# Install
Install from R-Universe:
```r
install.packages("ggflags", repos = c(
"https://jimjam-slam.r-universe.dev",
"https://cloud.r-project.org"))
```
# Use
```{r demo, warning=FALSE}
library(ggplot2)
library(ggflags)
set.seed(1234)
d <- data.frame(
x = rnorm(50), y = rnorm(50),
country = sample(c("ar", "fr", "nz", "gb", "es", "ca", "lv", "qa"), 50, TRUE),
stringsAsFactors = FALSE
)
ggplot(d, aes(x = x, y = y, country = country, size = x)) +
geom_flag() +
scale_country() +
scale_size(range = c(0, 15))
```
The flag SVG assets, used under the [CC-BY licence](https://github.com/eosrei/emojione-color-font/blob/master/LICENSE-CC-BY.txt), are taken from the EmojiOne set: https://github.com/eosrei/emojione-color-font
(Note: the EmojiOne set doesn't include UK counties or US states!)
![](man/figures/flags.png)
(note: proof of principle only)