This dataset was posted by Magnus Skonberg on week 5 discussion board in DATA 607. The entire document about it can be found in this link: https://www.kaggle.com/unsdsn/world-happiness
The proposed analysis is:
Compare the (Happiness) Score and GDP per capita for the Top 20 countries to observe the correlation (if there is any).
Thus I will based my analysis in 2019 data.
## -- Attaching packages --------------------------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2 v purrr 0.3.4
## v tibble 3.0.3 v dplyr 1.0.2
## v tidyr 1.1.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.5.0
## -- Conflicts ------------------------------------------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
##
## src, summarize
## The following objects are masked from 'package:base':
##
## format.pval, units
# Get the data
data <- read.csv("https://raw.githubusercontent.com/jnataky/DATA-607/master/A2_Various_dataset_transformation/happy_data2019.csv")## [1] 156 9
## Overall.rank Country.or.region Score GDP.per.capita Social.support
## 1 1 Finland 7.769 1.340 1.587
## 2 2 Denmark 7.600 1.383 1.573
## 3 3 Norway 7.554 1.488 1.582
## 4 4 Iceland 7.494 1.380 1.624
## 5 5 Netherlands 7.488 1.396 1.522
## 6 6 Switzerland 7.480 1.452 1.526
## Healthy.life.expectancy Freedom.to.make.life.choices Generosity
## 1 0.986 0.596 0.153
## 2 0.996 0.592 0.252
## 3 1.028 0.603 0.271
## 4 1.026 0.591 0.354
## 5 0.999 0.557 0.322
## 6 1.052 0.572 0.263
## Perceptions.of.corruption
## 1 0.393
## 2 0.410
## 3 0.341
## 4 0.118
## 5 0.298
## 6 0.343
## [1] 0
## [1] "Overall.rank" "Country.or.region"
## [3] "Score" "GDP.per.capita"
## [5] "Social.support" "Healthy.life.expectancy"
## [7] "Freedom.to.make.life.choices" "Generosity"
## [9] "Perceptions.of.corruption"
# create new data frame with necessary variables for analysis
data1 <- data_copy1 %>%
select(country, happiness_score, GDP_per_capita)data2 %>%
kbl(caption = "Countries rank for Happiness & GDP per capita", align = 'c') %>%
kable_material(c("striped", "hover")) %>%
row_spec(0, color = "indigo")| country | happiness_score | GDP_per_capita |
|---|---|---|
| Finland | 7.769 | 1.340 |
| Denmark | 7.600 | 1.383 |
| Norway | 7.554 | 1.488 |
| Iceland | 7.494 | 1.380 |
| Netherlands | 7.488 | 1.396 |
| Switzerland | 7.480 | 1.452 |
| Sweden | 7.343 | 1.387 |
| New Zealand | 7.307 | 1.303 |
| Canada | 7.278 | 1.365 |
| Austria | 7.246 | 1.376 |
| Australia | 7.228 | 1.372 |
| Costa Rica | 7.167 | 1.034 |
| Israel | 7.139 | 1.276 |
| Luxembourg | 7.090 | 1.609 |
| United Kingdom | 7.054 | 1.333 |
| Ireland | 7.021 | 1.499 |
| Germany | 6.985 | 1.373 |
| Belgium | 6.923 | 1.356 |
| United States | 6.892 | 1.433 |
| Czech Republic | 6.852 | 1.269 |
ggplot(data = data2) +
geom_point(mapping = aes(x = GDP_per_capita, y = happiness_score, color = country)) +
geom_smooth(mapping = aes( x = GDP_per_capita, y = happiness_score), se = FALSE, color = "red")## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
There is not a linear relationship between GDP_per_capita and happiness or it is just a very small association between GDP per capita and happiness.
Let calculate to verify this by calculation:
## [1] 0.08958574
As Rousseau write in 1750: “Money buys everything, except morality and citizens.” Used ironically as “MONEY CAN’T BUY HAPPINESS”…
We can confirm from this analysis that money can’t buy happiness as there is very small association between GDP per capita and happiness.