Skip to content

Instantly share code, notes, and snippets.

@stared
Last active January 7, 2023 16:45
Show Gist options
  • Save stared/ee607314c6581d9ba6141bb7d3a5b033 to your computer and use it in GitHub Desktop.
Save stared/ee607314c6581d9ba6141bb7d3a5b033 to your computer and use it in GitHub Desktop.
Metal bands bring happiness (as chocolate brings Nobel Prizes) - ggplot2 code
Country or region Overall rank Metal bands per capita Score GDP per capita Social support Healthy life expectancy Freedom to make life choices Generosity Perceptions of corruption
Finland 1 630 7.809 1.285 1.5 0.961 0.662 0.16 0.478
Sweden 7 428 7.353 1.322 1.433 0.986 0.65 0.273 0.442
Iceland 4 341 7.504 1.327 1.548 1.001 0.662 0.362 0.145
Norway 5 299 7.488 1.424 1.495 1.008 0.67 0.288 0.434
Greece 77 162 5.515 1.128 1.169 0.979 0.174 0 0.049
Denmark 2 154 7.646 1.327 1.503 0.979 0.665 0.243 0.495
Luxembourg 10 144 7.238 1.537 1.388 0.986 0.61 0.196 0.367
Estonia 51 138 6.022 1.192 1.453 0.843 0.577 0.125 0.202
Malta 22 137 6.773 1.253 1.443 0.972 0.633 0.341 0.179
Netherlands 6 127 7.449 1.339 1.464 0.976 0.614 0.336 0.369
Austria 9 123 7.294 1.317 1.437 1.001 0.603 0.256 0.281
Germany 17 122 7.076 1.314 1.369 0.972 0.564 0.252 0.309
Czech Republic 19 120 6.911 1.212 1.405 0.895 0.506 0.046 0.05
Slovenia 33 120 6.363 1.209 1.465 0.933 0.647 0.146 0.077
Switzerland 3 112 7.56 1.391 1.472 1.041 0.629 0.269 0.408
Portugal 59 112 5.911 1.169 1.34 0.979 0.59 0.053 0.028
Hungary 53 105 6 1.164 1.423 0.807 0.386 0.07 0.028
Belgium 20 101 6.864 1.296 1.399 0.965 0.5 0.147 0.209
Italy 30 97 6.387 1.236 1.347 1.023 0.321 0.17 0.04
Slovakia 37 93 6.281 1.195 1.424 0.853 0.424 0.117 0.011
Croatia 79 90 5.505 1.109 1.311 0.901 0.381 0.114 0.012
Poland 43 80 6.186 1.169 1.31 0.868 0.558 0.063 0.161
Ireland 16 78 7.094 1.447 1.471 0.976 0.588 0.295 0.373
France 23 69 6.664 1.268 1.459 1.03 0.514 0.113 0.227
United Kingdom 13 68 7.165 1.273 1.458 0.976 0.525 0.373 0.323
Spain 28 65 6.401 1.231 1.421 1.051 0.426 0.165 0.11
Lithuania 41 54 6.215 1.194 1.433 0.795 0.42 0.054 0.081
Cyprus 45 52 6.159 1.213 1.149 1.026 0.459 0.228 0.051
Serbia 64 51 5.778 0.988 1.327 0.828 0.395 0.15 0.059
Latvia 57 48 5.95 1.141 1.414 0.778 0.329 0.075 0.09
Bulgaria 96 47 5.102 1.047 1.461 0.778 0.418 0.104 0
North Macedonia 90 44 5.16 0.935 1.183 0.803 0.41 0.186 0.025
Belarus 75 34 5.54 1.019 1.387 0.753 0.291 0.09 0.194
Bosnia and Herzegovina 69 31 5.674 0.918 1.204 0.814 0.305 0.264 0.001
Russia 73 22 5.546 1.127 1.379 0.68 0.399 0.099 0.046
Romania 47 18 6.124 1.12 1.194 0.792 0.535 0.068 0.001
Ukraine 123 17 4.561 0.78 1.321 0.699 0.319 0.179 0.01
Montenegro 72 14 5.546 1.01 1.266 0.839 0.303 0.149 0.098
Turkey 93 6 5.132 1.127 1.197 0.781 0.254 0.086 0.121
Albania 105 4 4.883 0.907 0.83 0.846 0.462 0.171 0.025
---
title: "Metal bands bring happiness"
output: html_notebook
author: "Piotr Migdał"
---
```{r}
library(ggplot2)
library(ggrepel)
```
```{r}
df <- read.csv("./metal_bands_happiness.csv")
```
```{r}
ggplot(df, aes(x=Metal.bands.per.capita, y=Score, label=Country.or.region)) +
scale_x_log10() +
stat_smooth(method = "lm", size = 0.5, alpha = 0.2) +
geom_point(color = "red", size = 0.5) +
geom_text_repel(size = 3, point.size = 0.5, segment.alpha = 0.5, segment.color = "red") +
xlab("Metal bands per 1M people") +
ylab("Average happiness score") +
labs(caption = "Data sources: Enc. Metallum (2016), after Jakub Marian; World Happiness Report (2022). Chart by Piotr Migdał, p.migdal.pl, CC-BY.")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment