World Happiness Index 2021

Author

Sameer Qureshi

Introduction

The World Happiness Report 2021 dataset, sourced from Kaggle, offers a detailed analysis of happiness levels across different countries. Published annually by the United Nations Sustainable Development Solutions Network (UNSDSN), this dataset provides valuable insights into global well-being trends. It encompasses various factors contributing to happiness, including economic prosperity, social support, healthy life expectancy, freedom to make life choices, generosity, and perceptions of corruption.

Variables Description

The dataset includes multiple variables, such as the country name and regional indicator, as well as:

- Social Support: Measures the extent of social support within the country.

- Healthy Life Expectancy: Represents the average life expectancy within the country.

- Freedom to Make Life Choices: Reflects the degree of freedom individuals have within the country in life choices.

- Generosity: Measures the level of generosity within the country.

- Perceptions of Corruption: Measures the perceived level of corruption within the country.

Observation Characteristics

- The dataset covers multiple countries worldwide.

- Each observation represents a specific country.

- Data for the most recent year (2021) is included.

The World Happiness Report dataset holds relevance for both business and social science disciplines. Businesses can use insights from the dataset to inform corporate social responsibility initiatives, employee well-being programs, and marketing strategies. Social scientists can leverage the dataset to study global happiness trends, explore the impact of socio-economic factors on well-being, and inform policy interventions.

Objectives:

  • To evaluate the relationship between economic indicators and happiness scores to understand how economic well-being contributes to overall happiness levels globally.

  • Assess the distribution of social factors across different regions to identify trends in societal well being.

Explore the Relationship Between Economic Indicators and Happiness Scores

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.2     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.1     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(janitor)

Attaching package: 'janitor'

The following objects are masked from 'package:stats':

    chisq.test, fisher.test
library(gt)
library(dplyr)
#dataset World Happiness Report 2021
happiness_data <- read.csv("~/Downloads/world-happiness-report-2021.csv")
str(happiness_data)
'data.frame':   149 obs. of  20 variables:
 $ Country.name                              : chr  "Finland" "Denmark" "Switzerland" "Iceland" ...
 $ Regional.indicator                        : chr  "Western Europe" "Western Europe" "Western Europe" "Western Europe" ...
 $ Ladder.score                              : num  7.84 7.62 7.57 7.55 7.46 ...
 $ Standard.error.of.ladder.score            : num  0.032 0.035 0.036 0.059 0.027 0.035 0.036 0.037 0.04 0.036 ...
 $ upperwhisker                              : num  7.9 7.69 7.64 7.67 7.52 ...
 $ lowerwhisker                              : num  7.78 7.55 7.5 7.44 7.41 ...
 $ Logged.GDP.per.capita                     : num  10.8 10.9 11.1 10.9 10.9 ...
 $ Social.support                            : num  0.954 0.954 0.942 0.983 0.942 0.954 0.934 0.908 0.948 0.934 ...
 $ Healthy.life.expectancy                   : num  72 72.7 74.4 73 72.4 73.3 72.7 72.6 73.4 73.3 ...
 $ Freedom.to.make.life.choices              : num  0.949 0.946 0.919 0.955 0.913 0.96 0.945 0.907 0.929 0.908 ...
 $ Generosity                                : num  -0.098 0.03 0.025 0.16 0.175 0.093 0.086 -0.034 0.134 0.042 ...
 $ Perceptions.of.corruption                 : num  0.186 0.179 0.292 0.673 0.338 0.27 0.237 0.386 0.242 0.481 ...
 $ Ladder.score.in.Dystopia                  : num  2.43 2.43 2.43 2.43 2.43 2.43 2.43 2.43 2.43 2.43 ...
 $ Explained.by..Log.GDP.per.capita          : num  1.45 1.5 1.57 1.48 1.5 ...
 $ Explained.by..Social.support              : num  1.11 1.11 1.08 1.17 1.08 ...
 $ Explained.by..Healthy.life.expectancy     : num  0.741 0.763 0.816 0.772 0.753 0.782 0.763 0.76 0.785 0.782 ...
 $ Explained.by..Freedom.to.make.life.choices: num  0.691 0.686 0.653 0.698 0.647 0.703 0.685 0.639 0.665 0.64 ...
 $ Explained.by..Generosity                  : num  0.124 0.208 0.204 0.293 0.302 0.249 0.244 0.166 0.276 0.215 ...
 $ Explained.by..Perceptions.of.corruption   : num  0.481 0.485 0.413 0.17 0.384 0.427 0.448 0.353 0.445 0.292 ...
 $ Dystopia...residual                       : num  3.25 2.87 2.84 2.97 2.8 ...
ggplot(happiness_data, aes(x = `Logged.GDP.per.capita`, y = `Ladder.score`)) +
  geom_point() +
  labs(x = "GDP per Capita", y = "Happiness Score") +
  ggtitle("Scatter Plot: GDP per Capita vs. Happiness Score")

Interpretation: The x-axis represents the GDP per Capita (economic prosperity) of different regions across the world. Higher values on the x-axis indicate a higher GDP per capita. The y-axis represents the Happiness Score (life satisfaction) of the regions across the world. Higher values on the y-axis indicate higher happiness scores. Each black dot represents a specific region or country. There is a visible trend, as GDP per Capita increases, so does the Happiness score. This depicts a positive correlation between econonmic prosperity and perceived happiness. Regions with higher economic well-being tend to have happier populations.

# 2. Bar Chart: “Economic Prosperity and Happiness”

ggplot(happiness_data, aes(x = `Logged.GDP.per.capita`, y = `Social.support`)) +
  geom_bar(stat = "identity", color = "red") +
  labs(x = "GDP per Capita", y = "Social Support") +
  ggtitle("Bar Chart: GDP per Capita vs. Social Support")

Interpretation: The x-axis represents the GDP per Capita of different regions. The Y-axis represents the Social Support available in the same regions. Each red bar corresponds to a specific data point, and the height of each bar represents the level of social support at a given GDP per Capita value. The bar chart visually shows the relationship between economic prosperity and the availability of social support. Regions with higher GDP per Capita tend to have better social support systems.

#3. Box Plot: Distribution of Healthy Life Expectancy by Region

ggplot(happiness_data, aes(x = Regional.indicator, y = `Ladder.score`, fill = Regional.indicator)) +
  geom_boxplot() +
  labs(x = "Healthy Life Expectancy", y = "Happiness Score") +
  ggtitle("Box Plot: Healthy Life Expectancy vs. Happiness Score")

Interpretation: The x-axis represents the Healthy Life Expectancy of different regions. The y-axis represents the Happiness score in the same regions. Each colored box corresponds to a specific country and region. The box plot visually shows the relationship between both variables across different regions. The position of the box indicates the median happiness score for that region.

#4. Descriptive Table: Summary Statistics of Economic Indicators

economic_indicators_summary <- summary(happiness_data[c("Logged.GDP.per.capita", "Ladder.score")])
economic_indicators_summary
 Logged.GDP.per.capita  Ladder.score  
 Min.   : 6.635        Min.   :2.523  
 1st Qu.: 8.541        1st Qu.:4.852  
 Median : 9.569        Median :5.534  
 Mean   : 9.432        Mean   :5.533  
 3rd Qu.:10.421        3rd Qu.:6.255  
 Max.   :11.647        Max.   :7.842  

#Descriptive Table: Summary Statistics of Social Factors

social_factors_summary <- summary(happiness_data[c("Social.support", "Freedom.to.make.life.choices", "Generosity")])
social_factors_summary
 Social.support   Freedom.to.make.life.choices   Generosity      
 Min.   :0.4630   Min.   :0.3820               Min.   :-0.28800  
 1st Qu.:0.7500   1st Qu.:0.7180               1st Qu.:-0.12600  
 Median :0.8320   Median :0.8040               Median :-0.03600  
 Mean   :0.8147   Mean   :0.7916               Mean   :-0.01513  
 3rd Qu.:0.9050   3rd Qu.:0.8770               3rd Qu.: 0.07900  
 Max.   :0.9830   Max.   :0.9700               Max.   : 0.54200  

Descriptive Table: To analyze and visualize the average levels of generosity and social support across different regions in the dataset.

generosity_social_summary <- happiness_data %>%
  select(Regional.indicator, Generosity, `Social.support`) %>%
  group_by(Regional.indicator) %>%
  summarise(
    Mean_Generosity = mean(Generosity),
    Mean_Social_Support = mean(`Social.support`)
  )

gt(generosity_social_summary)
Regional.indicator Mean_Generosity Mean_Social_Support
Central and Eastern Europe -0.078941176 0.8874118
Commonwealth of Independent States -0.036000000 0.8725000
East Asia -0.062333333 0.8605000
Latin America and Caribbean -0.067700000 0.8395000
Middle East and North Africa -0.079764706 0.7976471
North America and ANZ 0.120000000 0.9335000
South Asia 0.042714286 0.7034286
Southeast Asia 0.156333333 0.8203333
Sub-Saharan Africa 0.013444444 0.6967500
Western Europe -0.003190476 0.9144762

Bar Chart: Happiness Scores vs. Social Support by Region

ggplot(happiness_data, aes(x = Regional.indicator, y = Ladder.score, fill = Regional.indicator)) +
  geom_bar(stat = "identity") +
  labs(x = "Social Support", y = "Happiness Score", title = "Happiness Scores vs. Social Support by Region")

Interpretation: The x-axis represents the social support levels across different regions around the world and the y-axis represents the happiness score for each region. Each colored bar represents a specific region, the taller the bar, the higher the happiness score for that region. Western Europe and North America & ANZ exhibit higher happiness scores, whereas South Asia has a lower score comparatively.

iv) Data Wrangling techniques

  • Cleaning Dataset

To remove unnecessary columns (Explained.by..Log.GDP.per.capita, Explained.by..Social.support, etc.) from the dataset to focus only on the relevant variables for analysis.

cleaned_dataset <- happiness_data %>%
  select(-Explained.by..Log.GDP.per.capita, 
         -Explained.by..Social.support, 
         -Explained.by..Healthy.life.expectancy, 
         -Explained.by..Freedom.to.make.life.choices, 
         -Explained.by..Generosity, 
         -Explained.by..Perceptions.of.corruption) 

print(cleaned_dataset)
                 Country.name                 Regional.indicator Ladder.score
1                     Finland                     Western Europe        7.842
2                     Denmark                     Western Europe        7.620
3                 Switzerland                     Western Europe        7.571
4                     Iceland                     Western Europe        7.554
5                 Netherlands                     Western Europe        7.464
6                      Norway                     Western Europe        7.392
7                      Sweden                     Western Europe        7.363
8                  Luxembourg                     Western Europe        7.324
9                 New Zealand              North America and ANZ        7.277
10                    Austria                     Western Europe        7.268
11                  Australia              North America and ANZ        7.183
12                     Israel       Middle East and North Africa        7.157
13                    Germany                     Western Europe        7.155
14                     Canada              North America and ANZ        7.103
15                    Ireland                     Western Europe        7.085
16                 Costa Rica        Latin America and Caribbean        7.069
17             United Kingdom                     Western Europe        7.064
18             Czech Republic         Central and Eastern Europe        6.965
19              United States              North America and ANZ        6.951
20                    Belgium                     Western Europe        6.834
21                     France                     Western Europe        6.690
22                    Bahrain       Middle East and North Africa        6.647
23                      Malta                     Western Europe        6.602
24   Taiwan Province of China                          East Asia        6.584
25       United Arab Emirates       Middle East and North Africa        6.561
26               Saudi Arabia       Middle East and North Africa        6.494
27                      Spain                     Western Europe        6.491
28                      Italy                     Western Europe        6.483
29                   Slovenia         Central and Eastern Europe        6.461
30                  Guatemala        Latin America and Caribbean        6.435
31                    Uruguay        Latin America and Caribbean        6.431
32                  Singapore                     Southeast Asia        6.377
33                     Kosovo         Central and Eastern Europe        6.372
34                   Slovakia         Central and Eastern Europe        6.331
35                     Brazil        Latin America and Caribbean        6.330
36                     Mexico        Latin America and Caribbean        6.317
37                    Jamaica        Latin America and Caribbean        6.309
38                  Lithuania         Central and Eastern Europe        6.255
39                     Cyprus                     Western Europe        6.223
40                    Estonia         Central and Eastern Europe        6.189
41                     Panama        Latin America and Caribbean        6.180
42                 Uzbekistan Commonwealth of Independent States        6.179
43                      Chile        Latin America and Caribbean        6.172
44                     Poland         Central and Eastern Europe        6.166
45                 Kazakhstan Commonwealth of Independent States        6.152
46                    Romania         Central and Eastern Europe        6.140
47                     Kuwait       Middle East and North Africa        6.106
48                     Serbia         Central and Eastern Europe        6.078
49                El Salvador        Latin America and Caribbean        6.061
50                  Mauritius                 Sub-Saharan Africa        6.049
51                     Latvia         Central and Eastern Europe        6.032
52                   Colombia        Latin America and Caribbean        6.012
53                    Hungary         Central and Eastern Europe        5.992
54                   Thailand                     Southeast Asia        5.985
55                  Nicaragua        Latin America and Caribbean        5.972
56                      Japan                          East Asia        5.940
57                  Argentina        Latin America and Caribbean        5.929
58                   Portugal                     Western Europe        5.929
59                   Honduras        Latin America and Caribbean        5.919
60                    Croatia         Central and Eastern Europe        5.882
61                Philippines                     Southeast Asia        5.880
62                South Korea                          East Asia        5.845
63                       Peru        Latin America and Caribbean        5.840
64     Bosnia and Herzegovina         Central and Eastern Europe        5.813
65                    Moldova Commonwealth of Independent States        5.766
66                    Ecuador        Latin America and Caribbean        5.764
67                 Kyrgyzstan Commonwealth of Independent States        5.744
68                     Greece                     Western Europe        5.723
69                    Bolivia        Latin America and Caribbean        5.716
70                   Mongolia                          East Asia        5.677
71                   Paraguay        Latin America and Caribbean        5.653
72                 Montenegro         Central and Eastern Europe        5.581
73         Dominican Republic        Latin America and Caribbean        5.545
74               North Cyprus                     Western Europe        5.536
75                    Belarus Commonwealth of Independent States        5.534
76                     Russia Commonwealth of Independent States        5.477
77  Hong Kong S.A.R. of China                          East Asia        5.477
78                 Tajikistan Commonwealth of Independent States        5.466
79                    Vietnam                     Southeast Asia        5.411
80                      Libya       Middle East and North Africa        5.410
81                   Malaysia                     Southeast Asia        5.384
82                  Indonesia                     Southeast Asia        5.345
83        Congo (Brazzaville)                 Sub-Saharan Africa        5.342
84                      China                          East Asia        5.339
85                Ivory Coast                 Sub-Saharan Africa        5.306
86                    Armenia Commonwealth of Independent States        5.283
87                      Nepal                         South Asia        5.269
88                   Bulgaria         Central and Eastern Europe        5.266
89                   Maldives                         South Asia        5.198
90                 Azerbaijan Commonwealth of Independent States        5.171
91                   Cameroon                 Sub-Saharan Africa        5.142
92                    Senegal                 Sub-Saharan Africa        5.132
93                    Albania         Central and Eastern Europe        5.117
94            North Macedonia         Central and Eastern Europe        5.101
95                      Ghana                 Sub-Saharan Africa        5.088
96                      Niger                 Sub-Saharan Africa        5.074
97               Turkmenistan Commonwealth of Independent States        5.066
98                     Gambia                 Sub-Saharan Africa        5.051
99                      Benin                 Sub-Saharan Africa        5.045
100                      Laos                     Southeast Asia        5.030
101                Bangladesh                         South Asia        5.025
102                    Guinea                 Sub-Saharan Africa        4.984
103              South Africa                 Sub-Saharan Africa        4.956
104                    Turkey       Middle East and North Africa        4.948
105                  Pakistan                         South Asia        4.934
106                   Morocco       Middle East and North Africa        4.918
107                 Venezuela        Latin America and Caribbean        4.892
108                   Georgia Commonwealth of Independent States        4.891
109                   Algeria       Middle East and North Africa        4.887
110                   Ukraine Commonwealth of Independent States        4.875
111                      Iraq       Middle East and North Africa        4.854
112                     Gabon                 Sub-Saharan Africa        4.852
113              Burkina Faso                 Sub-Saharan Africa        4.834
114                  Cambodia                     Southeast Asia        4.830
115                Mozambique                 Sub-Saharan Africa        4.794
116                   Nigeria                 Sub-Saharan Africa        4.759
117                      Mali                 Sub-Saharan Africa        4.723
118                      Iran       Middle East and North Africa        4.721
119                    Uganda                 Sub-Saharan Africa        4.636
120                   Liberia                 Sub-Saharan Africa        4.625
121                     Kenya                 Sub-Saharan Africa        4.607
122                   Tunisia       Middle East and North Africa        4.596
123                   Lebanon       Middle East and North Africa        4.584
124                   Namibia                 Sub-Saharan Africa        4.574
125   Palestinian Territories       Middle East and North Africa        4.517
126                   Myanmar                     Southeast Asia        4.426
127                    Jordan       Middle East and North Africa        4.395
128                      Chad                 Sub-Saharan Africa        4.355
129                 Sri Lanka                         South Asia        4.325
130                 Swaziland                 Sub-Saharan Africa        4.308
131                   Comoros                 Sub-Saharan Africa        4.289
132                     Egypt       Middle East and North Africa        4.283
133                  Ethiopia                 Sub-Saharan Africa        4.275
134                Mauritania                 Sub-Saharan Africa        4.227
135                Madagascar                 Sub-Saharan Africa        4.208
136                      Togo                 Sub-Saharan Africa        4.107
137                    Zambia                 Sub-Saharan Africa        4.073
138              Sierra Leone                 Sub-Saharan Africa        3.849
139                     India                         South Asia        3.819
140                   Burundi                 Sub-Saharan Africa        3.775
141                     Yemen       Middle East and North Africa        3.658
142                  Tanzania                 Sub-Saharan Africa        3.623
143                     Haiti        Latin America and Caribbean        3.615
144                    Malawi                 Sub-Saharan Africa        3.600
145                   Lesotho                 Sub-Saharan Africa        3.512
146                  Botswana                 Sub-Saharan Africa        3.467
147                    Rwanda                 Sub-Saharan Africa        3.415
148                  Zimbabwe                 Sub-Saharan Africa        3.145
149               Afghanistan                         South Asia        2.523
    Standard.error.of.ladder.score upperwhisker lowerwhisker
1                            0.032        7.904        7.780
2                            0.035        7.687        7.552
3                            0.036        7.643        7.500
4                            0.059        7.670        7.438
5                            0.027        7.518        7.410
6                            0.035        7.462        7.323
7                            0.036        7.433        7.293
8                            0.037        7.396        7.252
9                            0.040        7.355        7.198
10                           0.036        7.337        7.198
11                           0.041        7.265        7.102
12                           0.034        7.224        7.090
13                           0.040        7.232        7.077
14                           0.042        7.185        7.021
15                           0.040        7.164        7.006
16                           0.056        7.179        6.960
17                           0.038        7.138        6.990
18                           0.049        7.062        6.868
19                           0.049        7.047        6.856
20                           0.034        6.901        6.767
21                           0.037        6.762        6.618
22                           0.068        6.779        6.514
23                           0.044        6.688        6.516
24                           0.038        6.659        6.510
25                           0.039        6.637        6.484
26                           0.056        6.604        6.384
27                           0.042        6.574        6.408
28                           0.045        6.572        6.395
29                           0.043        6.546        6.376
30                           0.073        6.577        6.292
31                           0.046        6.521        6.341
32                           0.043        6.460        6.293
33                           0.059        6.487        6.257
34                           0.041        6.411        6.251
35                           0.043        6.415        6.245
36                           0.053        6.420        6.213
37                           0.156        6.615        6.004
38                           0.045        6.344        6.167
39                           0.049        6.319        6.128
40                           0.038        6.263        6.115
41                           0.073        6.323        6.036
42                           0.068        6.312        6.045
43                           0.046        6.262        6.081
44                           0.040        6.245        6.087
45                           0.047        6.243        6.060
46                           0.057        6.253        6.027
47                           0.066        6.235        5.977
48                           0.053        6.181        5.974
49                           0.065        6.188        5.933
50                           0.059        6.165        5.933
51                           0.036        6.103        5.961
52                           0.061        6.132        5.892
53                           0.047        6.085        5.899
54                           0.047        6.077        5.893
55                           0.083        6.134        5.810
56                           0.040        6.020        5.861
57                           0.056        6.040        5.819
58                           0.055        6.037        5.821
59                           0.082        6.081        5.758
60                           0.048        5.975        5.788
61                           0.052        5.982        5.778
62                           0.042        5.928        5.763
63                           0.075        5.988        5.692
64                           0.050        5.911        5.715
65                           0.046        5.856        5.677
66                           0.057        5.875        5.653
67                           0.046        5.834        5.653
68                           0.046        5.813        5.632
69                           0.053        5.819        5.613
70                           0.042        5.760        5.595
71                           0.092        5.832        5.473
72                           0.054        5.686        5.475
73                           0.071        5.685        5.405
74                           0.051        5.636        5.435
75                           0.047        5.625        5.442
76                           0.033        5.541        5.413
77                           0.049        5.573        5.380
78                           0.034        5.532        5.400
79                           0.039        5.488        5.334
80                           0.076        5.558        5.262
81                           0.049        5.480        5.289
82                           0.056        5.454        5.235
83                           0.097        5.533        5.151
84                           0.029        5.397        5.281
85                           0.078        5.460        5.152
86                           0.058        5.397        5.168
87                           0.070        5.406        5.132
88                           0.054        5.371        5.160
89                           0.072        5.339        5.057
90                           0.040        5.250        5.091
91                           0.074        5.288        4.996
92                           0.068        5.266        4.998
93                           0.059        5.234        5.001
94                           0.051        5.202        5.001
95                           0.067        5.219        4.958
96                           0.102        5.273        4.875
97                           0.036        5.136        4.996
98                           0.089        5.225        4.877
99                           0.073        5.189        4.901
100                          0.045        5.119        4.941
101                          0.046        5.115        4.934
102                          0.090        5.160        4.808
103                          0.060        5.074        4.839
104                          0.046        5.038        4.857
105                          0.068        5.066        4.802
106                          0.060        5.036        4.800
107                          0.064        5.017        4.767
108                          0.054        4.998        4.785
109                          0.053        4.991        4.783
110                          0.052        4.977        4.773
111                          0.059        4.970        4.738
112                          0.075        4.998        4.706
113                          0.081        4.993        4.675
114                          0.067        4.963        4.698
115                          0.103        4.997        4.592
116                          0.052        4.861        4.658
117                          0.082        4.884        4.563
118                          0.055        4.828        4.614
119                          0.073        4.780        4.493
120                          0.106        4.833        4.417
121                          0.072        4.747        4.466
122                          0.058        4.709        4.484
123                          0.055        4.691        4.477
124                          0.064        4.700        4.448
125                          0.067        4.649        4.384
126                          0.052        4.527        4.324
127                          0.062        4.516        4.273
128                          0.094        4.540        4.171
129                          0.066        4.454        4.196
130                          0.071        4.448        4.168
131                          0.084        4.454        4.123
132                          0.045        4.371        4.195
133                          0.051        4.374        4.175
134                          0.070        4.365        4.090
135                          0.072        4.349        4.068
136                          0.077        4.258        3.956
137                          0.069        4.209        3.938
138                          0.077        4.001        3.698
139                          0.026        3.869        3.769
140                          0.107        3.985        3.565
141                          0.070        3.794        3.521
142                          0.071        3.762        3.485
143                          0.173        3.953        3.276
144                          0.092        3.781        3.419
145                          0.120        3.748        3.276
146                          0.074        3.611        3.322
147                          0.068        3.548        3.282
148                          0.058        3.259        3.030
149                          0.038        2.596        2.449
    Logged.GDP.per.capita Social.support Healthy.life.expectancy
1                  10.775          0.954                  72.000
2                  10.933          0.954                  72.700
3                  11.117          0.942                  74.400
4                  10.878          0.983                  73.000
5                  10.932          0.942                  72.400
6                  11.053          0.954                  73.300
7                  10.867          0.934                  72.700
8                  11.647          0.908                  72.600
9                  10.643          0.948                  73.400
10                 10.906          0.934                  73.300
11                 10.796          0.940                  73.900
12                 10.575          0.939                  73.503
13                 10.873          0.903                  72.500
14                 10.776          0.926                  73.800
15                 11.342          0.947                  72.400
16                  9.880          0.891                  71.400
17                 10.707          0.934                  72.500
18                 10.556          0.947                  70.807
19                 11.023          0.920                  68.200
20                 10.823          0.906                  72.199
21                 10.704          0.942                  74.000
22                 10.669          0.862                  69.495
23                 10.674          0.931                  72.200
24                 10.871          0.898                  69.600
25                 11.085          0.844                  67.333
26                 10.743          0.891                  66.603
27                 10.571          0.932                  74.700
28                 10.623          0.880                  73.800
29                 10.529          0.948                  71.400
30                  9.053          0.813                  64.958
31                  9.966          0.925                  69.100
32                 11.488          0.915                  76.953
33                  9.318          0.821                  63.813
34                 10.369          0.936                  69.201
35                  9.577          0.882                  66.601
36                  9.859          0.831                  68.597
37                  9.186          0.877                  67.500
38                 10.499          0.935                  67.906
39                 10.576          0.802                  73.898
40                 10.481          0.941                  68.800
41                 10.350          0.896                  69.652
42                  8.836          0.918                  65.255
43                 10.071          0.882                  70.000
44                 10.382          0.898                  69.702
45                 10.155          0.952                  65.200
46                 10.284          0.832                  67.355
47                 10.817          0.843                  66.900
48                  9.787          0.873                  68.600
49                  9.054          0.762                  66.402
50                 10.008          0.905                  66.701
51                 10.315          0.927                  67.100
52                  9.557          0.847                  68.001
53                 10.358          0.943                  68.000
54                  9.805          0.888                  67.401
55                  8.620          0.864                  67.657
56                 10.611          0.884                  75.100
57                  9.962          0.898                  69.000
58                 10.421          0.879                  72.600
59                  8.648          0.812                  67.300
60                 10.217          0.924                  70.799
61                  9.076          0.830                  62.000
62                 10.651          0.799                  73.900
63                  9.458          0.832                  68.250
64                  9.590          0.870                  68.098
65                  9.454          0.857                  65.699
66                  9.313          0.821                  68.800
67                  8.538          0.893                  64.401
68                 10.279          0.823                  72.600
69                  9.046          0.810                  63.901
70                  9.400          0.935                  62.500
71                  9.448          0.893                  65.900
72                  9.940          0.858                  68.699
73                  9.802          0.853                  66.102
74                 10.576          0.820                  73.898
75                  9.853          0.910                  66.253
76                 10.189          0.903                  64.703
77                 11.000          0.836                  76.820
78                  8.091          0.860                  64.281
79                  8.973          0.850                  68.034
80                  9.622          0.827                  62.300
81                 10.238          0.817                  67.102
82                  9.365          0.811                  62.236
83                  8.117          0.636                  58.221
84                  9.673          0.811                  69.593
85                  8.551          0.644                  50.114
86                  9.487          0.799                  67.055
87                  8.120          0.774                  64.233
88                 10.016          0.931                  67.000
89                  9.826          0.913                  70.600
90                  9.569          0.836                  65.656
91                  8.189          0.710                  53.515
92                  8.118          0.710                  59.802
93                  9.520          0.697                  68.999
94                  9.693          0.805                  65.474
95                  8.580          0.727                  57.586
96                  7.098          0.641                  53.780
97                  9.629          0.983                  62.409
98                  7.686          0.690                  55.160
99                  8.087          0.489                  54.713
100                 8.947          0.728                  58.968
101                 8.454          0.693                  64.800
102                 7.838          0.639                  55.008
103                 9.403          0.860                  56.904
104                10.240          0.822                  67.199
105                 8.458          0.651                  58.709
106                 8.903          0.560                  66.208
107                 9.073          0.861                  66.700
108                 9.585          0.671                  64.300
109                 9.342          0.802                  66.005
110                 9.436          0.888                  64.902
111                 9.240          0.746                  60.583
112                 9.603          0.776                  59.962
113                 7.678          0.672                  54.151
114                 8.360          0.765                  62.000
115                 7.158          0.744                  54.706
116                 8.533          0.740                  50.102
117                 7.744          0.724                  51.969
118                 9.584          0.710                  66.300
119                 7.677          0.781                  56.101
120                 7.288          0.720                  56.498
121                 8.361          0.688                  60.704
122                 9.266          0.691                  67.201
123                 9.626          0.848                  67.355
124                 9.161          0.818                  56.799
125                 8.485          0.826                  62.250
126                 8.541          0.779                  59.302
127                 9.182          0.767                  67.000
128                 7.364          0.619                  48.478
129                 9.470          0.827                  67.299
130                 9.065          0.770                  50.833
131                 8.031          0.626                  57.349
132                 9.367          0.750                  61.998
133                 7.694          0.764                  59.000
134                 8.542          0.795                  57.161
135                 7.396          0.686                  59.305
136                 7.362          0.569                  54.914
137                 8.145          0.708                  55.809
138                 7.434          0.630                  51.651
139                 8.755          0.603                  60.633
140                 6.635          0.490                  53.400
141                 7.578          0.832                  57.122
142                 7.876          0.702                  57.999
143                 7.477          0.540                  55.700
144                 6.958          0.537                  57.948
145                 7.926          0.787                  48.700
146                 9.782          0.784                  59.269
147                 7.676          0.552                  61.400
148                 7.943          0.750                  56.201
149                 7.695          0.463                  52.493
    Freedom.to.make.life.choices Generosity Perceptions.of.corruption
1                          0.949     -0.098                     0.186
2                          0.946      0.030                     0.179
3                          0.919      0.025                     0.292
4                          0.955      0.160                     0.673
5                          0.913      0.175                     0.338
6                          0.960      0.093                     0.270
7                          0.945      0.086                     0.237
8                          0.907     -0.034                     0.386
9                          0.929      0.134                     0.242
10                         0.908      0.042                     0.481
11                         0.914      0.159                     0.442
12                         0.800      0.031                     0.753
13                         0.875      0.011                     0.460
14                         0.915      0.089                     0.415
15                         0.879      0.077                     0.363
16                         0.934     -0.126                     0.809
17                         0.859      0.233                     0.459
18                         0.858     -0.208                     0.868
19                         0.837      0.098                     0.698
20                         0.783     -0.153                     0.646
21                         0.822     -0.147                     0.571
22                         0.925      0.089                     0.722
23                         0.927      0.133                     0.653
24                         0.784     -0.070                     0.721
25                         0.932      0.074                     0.589
26                         0.877     -0.149                     0.684
27                         0.761     -0.081                     0.745
28                         0.693     -0.084                     0.866
29                         0.949     -0.101                     0.806
30                         0.906     -0.038                     0.775
31                         0.896     -0.092                     0.590
32                         0.927     -0.018                     0.082
33                         0.869      0.257                     0.917
34                         0.766     -0.124                     0.911
35                         0.804     -0.071                     0.756
36                         0.862     -0.147                     0.799
37                         0.890     -0.137                     0.884
38                         0.773     -0.203                     0.826
39                         0.763     -0.015                     0.844
40                         0.909     -0.106                     0.527
41                         0.872     -0.166                     0.856
42                         0.970      0.311                     0.515
43                         0.742     -0.044                     0.830
44                         0.841     -0.165                     0.735
45                         0.853     -0.069                     0.733
46                         0.845     -0.219                     0.938
47                         0.867     -0.104                     0.736
48                         0.778      0.002                     0.835
49                         0.888     -0.110                     0.688
50                         0.867     -0.054                     0.789
51                         0.715     -0.162                     0.800
52                         0.837     -0.135                     0.841
53                         0.755     -0.186                     0.876
54                         0.884      0.287                     0.895
55                         0.836      0.020                     0.664
56                         0.796     -0.258                     0.638
57                         0.828     -0.182                     0.834
58                         0.892     -0.244                     0.887
59                         0.857      0.081                     0.809
60                         0.754     -0.118                     0.939
61                         0.917     -0.097                     0.742
62                         0.672     -0.083                     0.727
63                         0.822     -0.154                     0.891
64                         0.706      0.113                     0.931
65                         0.822     -0.079                     0.918
66                         0.842     -0.124                     0.843
67                         0.935      0.119                     0.908
68                         0.582     -0.288                     0.823
69                         0.875     -0.077                     0.839
70                         0.708      0.116                     0.856
71                         0.876      0.028                     0.882
72                         0.708     -0.034                     0.812
73                         0.860     -0.133                     0.714
74                         0.795      0.012                     0.626
75                         0.650     -0.180                     0.627
76                         0.718     -0.111                     0.845
77                         0.717      0.067                     0.403
78                         0.832     -0.056                     0.553
79                         0.940     -0.098                     0.796
80                         0.771     -0.087                     0.667
81                         0.895      0.125                     0.839
82                         0.873      0.542                     0.867
83                         0.695     -0.068                     0.745
84                         0.904     -0.146                     0.755
85                         0.741     -0.016                     0.794
86                         0.825     -0.168                     0.629
87                         0.782      0.152                     0.727
88                         0.788     -0.096                     0.932
89                         0.854      0.024                     0.825
90                         0.814     -0.223                     0.506
91                         0.731      0.026                     0.848
92                         0.695     -0.046                     0.801
93                         0.785     -0.030                     0.901
94                         0.751      0.038                     0.905
95                         0.807      0.123                     0.848
96                         0.806      0.018                     0.693
97                         0.877      0.273                     0.888
98                         0.697      0.424                     0.746
99                         0.757     -0.034                     0.661
100                        0.910      0.123                     0.658
101                        0.877     -0.041                     0.682
102                        0.697      0.095                     0.766
103                        0.749     -0.067                     0.860
104                        0.576     -0.139                     0.776
105                        0.726      0.098                     0.787
106                        0.774     -0.236                     0.801
107                        0.615     -0.169                     0.827
108                        0.783     -0.238                     0.655
109                        0.480     -0.067                     0.752
110                        0.724     -0.011                     0.924
111                        0.630     -0.053                     0.875
112                        0.731     -0.200                     0.840
113                        0.695     -0.009                     0.748
114                        0.959      0.034                     0.843
115                        0.882      0.061                     0.684
116                        0.737      0.037                     0.878
117                        0.697     -0.036                     0.827
118                        0.608      0.218                     0.714
119                        0.709      0.122                     0.855
120                        0.735      0.050                     0.850
121                        0.779      0.287                     0.825
122                        0.656     -0.201                     0.870
123                        0.525     -0.073                     0.898
124                        0.719     -0.149                     0.847
125                        0.653     -0.163                     0.821
126                        0.876      0.509                     0.660
127                        0.755     -0.167                     0.705
128                        0.579      0.041                     0.807
129                        0.841      0.079                     0.863
130                        0.647     -0.185                     0.708
131                        0.548      0.082                     0.781
132                        0.749     -0.182                     0.795
133                        0.752      0.082                     0.761
134                        0.561     -0.106                     0.731
135                        0.552     -0.005                     0.803
136                        0.619      0.032                     0.772
137                        0.782      0.061                     0.823
138                        0.717      0.084                     0.866
139                        0.893      0.089                     0.774
140                        0.626     -0.024                     0.607
141                        0.602     -0.147                     0.800
142                        0.833      0.183                     0.577
143                        0.593      0.422                     0.721
144                        0.780      0.038                     0.729
145                        0.715     -0.131                     0.915
146                        0.824     -0.246                     0.801
147                        0.897      0.061                     0.167
148                        0.677     -0.047                     0.821
149                        0.382     -0.102                     0.924
    Ladder.score.in.Dystopia Dystopia...residual
1                       2.43               3.253
2                       2.43               2.868
3                       2.43               2.839
4                       2.43               2.967
5                       2.43               2.798
6                       2.43               2.580
7                       2.43               2.683
8                       2.43               2.653
9                       2.43               2.612
10                      2.43               2.784
11                      2.43               2.598
12                      2.43               3.083
13                      2.43               2.824
14                      2.43               2.585
15                      2.43               2.384
16                      2.43               3.387
17                      2.43               2.596
18                      2.43               3.124
19                      2.43               2.807
20                      2.43               2.862
21                      2.43               2.521
22                      2.43               2.631
23                      2.43               2.268
24                      2.43               2.687
25                      2.43               2.422
26                      2.43               2.668
27                      2.43               2.513
28                      2.43               2.794
29                      2.43               2.388
30                      2.43               3.375
31                      2.43               2.600
32                      2.43               1.379
33                      2.43               3.182
34                      2.43               2.714
35                      2.43               3.015
36                      2.43               2.961
37                      2.43               3.135
38                      2.43               2.624
39                      2.43               2.578
40                      2.43               2.103
41                      2.43               2.509
42                      2.43               2.477
43                      2.43               2.682
44                      2.43               2.438
45                      2.43               2.446
46                      2.43               2.830
47                      2.43               2.368
48                      2.43               2.682
49                      2.43               3.085
50                      2.43               2.462
51                      2.43               2.536
52                      2.43               2.794
53                      2.43               2.432
54                      2.43               2.309
55                      2.43               2.841
56                      2.43               2.048
57                      2.43               2.461
58                      2.43               2.225
59                      2.43               2.934
60                      2.43               2.325
61                      2.43               2.872
62                      2.43               2.262
63                      2.43               2.744
64                      2.43               2.583
65                      2.43               2.665
66                      2.43               2.653
67                      2.43               2.648
68                      2.43               2.561
69                      2.43               2.805
70                      2.43               2.492
71                      2.43               2.306
72                      2.43               2.254
73                      2.43               2.178
74                      2.43               1.653
75                      2.43               2.247
76                      2.43               2.148
77                      2.43               1.236
78                      2.43               2.619
79                      2.43               2.211
80                      2.43               2.331
81                      2.43               1.784
82                      2.43               1.987
83                      2.43               3.476
84                      2.43               1.982
85                      2.43               3.469
86                      2.43               2.127
87                      2.43               2.642
88                      2.43               1.823
89                      2.43               1.520
90                      2.43               1.919
91                      2.43               3.195
92                      2.43               3.071
93                      2.43               2.250
94                      2.43               2.042
95                      2.43               2.684
96                      2.43               3.470
97                      2.43               1.409
98                      2.43               2.990
99                      2.43               3.482
100                     2.43               2.204
101                     2.43               2.427
102                     2.43               3.216
103                     2.43               2.187
104                     2.43               1.852
105                     2.43               2.784
106                     2.43               2.749
107                     2.43               2.135
108                     2.43               2.191
109                     2.43               2.242
110                     2.43               1.813
111                     2.43               2.429
112                     2.43               2.201
113                     2.43               3.133
114                     2.43               2.148
115                     2.43               2.783
116                     2.43               2.736
117                     2.43               3.016
118                     2.43               1.823
119                     2.43               2.596
120                     2.43               2.857
121                     2.43               2.180
122                     2.43               2.138
123                     2.43               1.736
124                     2.43               2.068
125                     2.43               2.131
126                     2.43               1.407
127                     2.43               1.553
128                     2.43               3.209
129                     2.43               1.075
130                     2.43               2.155
131                     2.43               2.610
132                     2.43               1.648
133                     2.43               2.089
134                     2.43               2.069
135                     2.43               2.620
136                     2.43               2.806
137                     2.43               1.975
138                     2.43               2.396
139                     2.43               1.405
140                     2.43               2.876
141                     2.43               1.776
142                     2.43               1.263
143                     2.43               2.060
144                     2.43               2.190
145                     2.43               1.800
146                     2.43               0.648
147                     2.43               1.095
148                     2.43               1.205
149                     2.43               1.895
  • Renaming columns to have more descriptive names
renamed_dataset <- cleaned_dataset %>%
  rename(
    Region = Regional.indicator,
    `Happiness Score` = Ladder.score,
    `Freedom To Make Life Choices` = Freedom.to.make.life.choices
  )

print (renamed_dataset)
                 Country.name                             Region
1                     Finland                     Western Europe
2                     Denmark                     Western Europe
3                 Switzerland                     Western Europe
4                     Iceland                     Western Europe
5                 Netherlands                     Western Europe
6                      Norway                     Western Europe
7                      Sweden                     Western Europe
8                  Luxembourg                     Western Europe
9                 New Zealand              North America and ANZ
10                    Austria                     Western Europe
11                  Australia              North America and ANZ
12                     Israel       Middle East and North Africa
13                    Germany                     Western Europe
14                     Canada              North America and ANZ
15                    Ireland                     Western Europe
16                 Costa Rica        Latin America and Caribbean
17             United Kingdom                     Western Europe
18             Czech Republic         Central and Eastern Europe
19              United States              North America and ANZ
20                    Belgium                     Western Europe
21                     France                     Western Europe
22                    Bahrain       Middle East and North Africa
23                      Malta                     Western Europe
24   Taiwan Province of China                          East Asia
25       United Arab Emirates       Middle East and North Africa
26               Saudi Arabia       Middle East and North Africa
27                      Spain                     Western Europe
28                      Italy                     Western Europe
29                   Slovenia         Central and Eastern Europe
30                  Guatemala        Latin America and Caribbean
31                    Uruguay        Latin America and Caribbean
32                  Singapore                     Southeast Asia
33                     Kosovo         Central and Eastern Europe
34                   Slovakia         Central and Eastern Europe
35                     Brazil        Latin America and Caribbean
36                     Mexico        Latin America and Caribbean
37                    Jamaica        Latin America and Caribbean
38                  Lithuania         Central and Eastern Europe
39                     Cyprus                     Western Europe
40                    Estonia         Central and Eastern Europe
41                     Panama        Latin America and Caribbean
42                 Uzbekistan Commonwealth of Independent States
43                      Chile        Latin America and Caribbean
44                     Poland         Central and Eastern Europe
45                 Kazakhstan Commonwealth of Independent States
46                    Romania         Central and Eastern Europe
47                     Kuwait       Middle East and North Africa
48                     Serbia         Central and Eastern Europe
49                El Salvador        Latin America and Caribbean
50                  Mauritius                 Sub-Saharan Africa
51                     Latvia         Central and Eastern Europe
52                   Colombia        Latin America and Caribbean
53                    Hungary         Central and Eastern Europe
54                   Thailand                     Southeast Asia
55                  Nicaragua        Latin America and Caribbean
56                      Japan                          East Asia
57                  Argentina        Latin America and Caribbean
58                   Portugal                     Western Europe
59                   Honduras        Latin America and Caribbean
60                    Croatia         Central and Eastern Europe
61                Philippines                     Southeast Asia
62                South Korea                          East Asia
63                       Peru        Latin America and Caribbean
64     Bosnia and Herzegovina         Central and Eastern Europe
65                    Moldova Commonwealth of Independent States
66                    Ecuador        Latin America and Caribbean
67                 Kyrgyzstan Commonwealth of Independent States
68                     Greece                     Western Europe
69                    Bolivia        Latin America and Caribbean
70                   Mongolia                          East Asia
71                   Paraguay        Latin America and Caribbean
72                 Montenegro         Central and Eastern Europe
73         Dominican Republic        Latin America and Caribbean
74               North Cyprus                     Western Europe
75                    Belarus Commonwealth of Independent States
76                     Russia Commonwealth of Independent States
77  Hong Kong S.A.R. of China                          East Asia
78                 Tajikistan Commonwealth of Independent States
79                    Vietnam                     Southeast Asia
80                      Libya       Middle East and North Africa
81                   Malaysia                     Southeast Asia
82                  Indonesia                     Southeast Asia
83        Congo (Brazzaville)                 Sub-Saharan Africa
84                      China                          East Asia
85                Ivory Coast                 Sub-Saharan Africa
86                    Armenia Commonwealth of Independent States
87                      Nepal                         South Asia
88                   Bulgaria         Central and Eastern Europe
89                   Maldives                         South Asia
90                 Azerbaijan Commonwealth of Independent States
91                   Cameroon                 Sub-Saharan Africa
92                    Senegal                 Sub-Saharan Africa
93                    Albania         Central and Eastern Europe
94            North Macedonia         Central and Eastern Europe
95                      Ghana                 Sub-Saharan Africa
96                      Niger                 Sub-Saharan Africa
97               Turkmenistan Commonwealth of Independent States
98                     Gambia                 Sub-Saharan Africa
99                      Benin                 Sub-Saharan Africa
100                      Laos                     Southeast Asia
101                Bangladesh                         South Asia
102                    Guinea                 Sub-Saharan Africa
103              South Africa                 Sub-Saharan Africa
104                    Turkey       Middle East and North Africa
105                  Pakistan                         South Asia
106                   Morocco       Middle East and North Africa
107                 Venezuela        Latin America and Caribbean
108                   Georgia Commonwealth of Independent States
109                   Algeria       Middle East and North Africa
110                   Ukraine Commonwealth of Independent States
111                      Iraq       Middle East and North Africa
112                     Gabon                 Sub-Saharan Africa
113              Burkina Faso                 Sub-Saharan Africa
114                  Cambodia                     Southeast Asia
115                Mozambique                 Sub-Saharan Africa
116                   Nigeria                 Sub-Saharan Africa
117                      Mali                 Sub-Saharan Africa
118                      Iran       Middle East and North Africa
119                    Uganda                 Sub-Saharan Africa
120                   Liberia                 Sub-Saharan Africa
121                     Kenya                 Sub-Saharan Africa
122                   Tunisia       Middle East and North Africa
123                   Lebanon       Middle East and North Africa
124                   Namibia                 Sub-Saharan Africa
125   Palestinian Territories       Middle East and North Africa
126                   Myanmar                     Southeast Asia
127                    Jordan       Middle East and North Africa
128                      Chad                 Sub-Saharan Africa
129                 Sri Lanka                         South Asia
130                 Swaziland                 Sub-Saharan Africa
131                   Comoros                 Sub-Saharan Africa
132                     Egypt       Middle East and North Africa
133                  Ethiopia                 Sub-Saharan Africa
134                Mauritania                 Sub-Saharan Africa
135                Madagascar                 Sub-Saharan Africa
136                      Togo                 Sub-Saharan Africa
137                    Zambia                 Sub-Saharan Africa
138              Sierra Leone                 Sub-Saharan Africa
139                     India                         South Asia
140                   Burundi                 Sub-Saharan Africa
141                     Yemen       Middle East and North Africa
142                  Tanzania                 Sub-Saharan Africa
143                     Haiti        Latin America and Caribbean
144                    Malawi                 Sub-Saharan Africa
145                   Lesotho                 Sub-Saharan Africa
146                  Botswana                 Sub-Saharan Africa
147                    Rwanda                 Sub-Saharan Africa
148                  Zimbabwe                 Sub-Saharan Africa
149               Afghanistan                         South Asia
    Happiness Score Standard.error.of.ladder.score upperwhisker lowerwhisker
1             7.842                          0.032        7.904        7.780
2             7.620                          0.035        7.687        7.552
3             7.571                          0.036        7.643        7.500
4             7.554                          0.059        7.670        7.438
5             7.464                          0.027        7.518        7.410
6             7.392                          0.035        7.462        7.323
7             7.363                          0.036        7.433        7.293
8             7.324                          0.037        7.396        7.252
9             7.277                          0.040        7.355        7.198
10            7.268                          0.036        7.337        7.198
11            7.183                          0.041        7.265        7.102
12            7.157                          0.034        7.224        7.090
13            7.155                          0.040        7.232        7.077
14            7.103                          0.042        7.185        7.021
15            7.085                          0.040        7.164        7.006
16            7.069                          0.056        7.179        6.960
17            7.064                          0.038        7.138        6.990
18            6.965                          0.049        7.062        6.868
19            6.951                          0.049        7.047        6.856
20            6.834                          0.034        6.901        6.767
21            6.690                          0.037        6.762        6.618
22            6.647                          0.068        6.779        6.514
23            6.602                          0.044        6.688        6.516
24            6.584                          0.038        6.659        6.510
25            6.561                          0.039        6.637        6.484
26            6.494                          0.056        6.604        6.384
27            6.491                          0.042        6.574        6.408
28            6.483                          0.045        6.572        6.395
29            6.461                          0.043        6.546        6.376
30            6.435                          0.073        6.577        6.292
31            6.431                          0.046        6.521        6.341
32            6.377                          0.043        6.460        6.293
33            6.372                          0.059        6.487        6.257
34            6.331                          0.041        6.411        6.251
35            6.330                          0.043        6.415        6.245
36            6.317                          0.053        6.420        6.213
37            6.309                          0.156        6.615        6.004
38            6.255                          0.045        6.344        6.167
39            6.223                          0.049        6.319        6.128
40            6.189                          0.038        6.263        6.115
41            6.180                          0.073        6.323        6.036
42            6.179                          0.068        6.312        6.045
43            6.172                          0.046        6.262        6.081
44            6.166                          0.040        6.245        6.087
45            6.152                          0.047        6.243        6.060
46            6.140                          0.057        6.253        6.027
47            6.106                          0.066        6.235        5.977
48            6.078                          0.053        6.181        5.974
49            6.061                          0.065        6.188        5.933
50            6.049                          0.059        6.165        5.933
51            6.032                          0.036        6.103        5.961
52            6.012                          0.061        6.132        5.892
53            5.992                          0.047        6.085        5.899
54            5.985                          0.047        6.077        5.893
55            5.972                          0.083        6.134        5.810
56            5.940                          0.040        6.020        5.861
57            5.929                          0.056        6.040        5.819
58            5.929                          0.055        6.037        5.821
59            5.919                          0.082        6.081        5.758
60            5.882                          0.048        5.975        5.788
61            5.880                          0.052        5.982        5.778
62            5.845                          0.042        5.928        5.763
63            5.840                          0.075        5.988        5.692
64            5.813                          0.050        5.911        5.715
65            5.766                          0.046        5.856        5.677
66            5.764                          0.057        5.875        5.653
67            5.744                          0.046        5.834        5.653
68            5.723                          0.046        5.813        5.632
69            5.716                          0.053        5.819        5.613
70            5.677                          0.042        5.760        5.595
71            5.653                          0.092        5.832        5.473
72            5.581                          0.054        5.686        5.475
73            5.545                          0.071        5.685        5.405
74            5.536                          0.051        5.636        5.435
75            5.534                          0.047        5.625        5.442
76            5.477                          0.033        5.541        5.413
77            5.477                          0.049        5.573        5.380
78            5.466                          0.034        5.532        5.400
79            5.411                          0.039        5.488        5.334
80            5.410                          0.076        5.558        5.262
81            5.384                          0.049        5.480        5.289
82            5.345                          0.056        5.454        5.235
83            5.342                          0.097        5.533        5.151
84            5.339                          0.029        5.397        5.281
85            5.306                          0.078        5.460        5.152
86            5.283                          0.058        5.397        5.168
87            5.269                          0.070        5.406        5.132
88            5.266                          0.054        5.371        5.160
89            5.198                          0.072        5.339        5.057
90            5.171                          0.040        5.250        5.091
91            5.142                          0.074        5.288        4.996
92            5.132                          0.068        5.266        4.998
93            5.117                          0.059        5.234        5.001
94            5.101                          0.051        5.202        5.001
95            5.088                          0.067        5.219        4.958
96            5.074                          0.102        5.273        4.875
97            5.066                          0.036        5.136        4.996
98            5.051                          0.089        5.225        4.877
99            5.045                          0.073        5.189        4.901
100           5.030                          0.045        5.119        4.941
101           5.025                          0.046        5.115        4.934
102           4.984                          0.090        5.160        4.808
103           4.956                          0.060        5.074        4.839
104           4.948                          0.046        5.038        4.857
105           4.934                          0.068        5.066        4.802
106           4.918                          0.060        5.036        4.800
107           4.892                          0.064        5.017        4.767
108           4.891                          0.054        4.998        4.785
109           4.887                          0.053        4.991        4.783
110           4.875                          0.052        4.977        4.773
111           4.854                          0.059        4.970        4.738
112           4.852                          0.075        4.998        4.706
113           4.834                          0.081        4.993        4.675
114           4.830                          0.067        4.963        4.698
115           4.794                          0.103        4.997        4.592
116           4.759                          0.052        4.861        4.658
117           4.723                          0.082        4.884        4.563
118           4.721                          0.055        4.828        4.614
119           4.636                          0.073        4.780        4.493
120           4.625                          0.106        4.833        4.417
121           4.607                          0.072        4.747        4.466
122           4.596                          0.058        4.709        4.484
123           4.584                          0.055        4.691        4.477
124           4.574                          0.064        4.700        4.448
125           4.517                          0.067        4.649        4.384
126           4.426                          0.052        4.527        4.324
127           4.395                          0.062        4.516        4.273
128           4.355                          0.094        4.540        4.171
129           4.325                          0.066        4.454        4.196
130           4.308                          0.071        4.448        4.168
131           4.289                          0.084        4.454        4.123
132           4.283                          0.045        4.371        4.195
133           4.275                          0.051        4.374        4.175
134           4.227                          0.070        4.365        4.090
135           4.208                          0.072        4.349        4.068
136           4.107                          0.077        4.258        3.956
137           4.073                          0.069        4.209        3.938
138           3.849                          0.077        4.001        3.698
139           3.819                          0.026        3.869        3.769
140           3.775                          0.107        3.985        3.565
141           3.658                          0.070        3.794        3.521
142           3.623                          0.071        3.762        3.485
143           3.615                          0.173        3.953        3.276
144           3.600                          0.092        3.781        3.419
145           3.512                          0.120        3.748        3.276
146           3.467                          0.074        3.611        3.322
147           3.415                          0.068        3.548        3.282
148           3.145                          0.058        3.259        3.030
149           2.523                          0.038        2.596        2.449
    Logged.GDP.per.capita Social.support Healthy.life.expectancy
1                  10.775          0.954                  72.000
2                  10.933          0.954                  72.700
3                  11.117          0.942                  74.400
4                  10.878          0.983                  73.000
5                  10.932          0.942                  72.400
6                  11.053          0.954                  73.300
7                  10.867          0.934                  72.700
8                  11.647          0.908                  72.600
9                  10.643          0.948                  73.400
10                 10.906          0.934                  73.300
11                 10.796          0.940                  73.900
12                 10.575          0.939                  73.503
13                 10.873          0.903                  72.500
14                 10.776          0.926                  73.800
15                 11.342          0.947                  72.400
16                  9.880          0.891                  71.400
17                 10.707          0.934                  72.500
18                 10.556          0.947                  70.807
19                 11.023          0.920                  68.200
20                 10.823          0.906                  72.199
21                 10.704          0.942                  74.000
22                 10.669          0.862                  69.495
23                 10.674          0.931                  72.200
24                 10.871          0.898                  69.600
25                 11.085          0.844                  67.333
26                 10.743          0.891                  66.603
27                 10.571          0.932                  74.700
28                 10.623          0.880                  73.800
29                 10.529          0.948                  71.400
30                  9.053          0.813                  64.958
31                  9.966          0.925                  69.100
32                 11.488          0.915                  76.953
33                  9.318          0.821                  63.813
34                 10.369          0.936                  69.201
35                  9.577          0.882                  66.601
36                  9.859          0.831                  68.597
37                  9.186          0.877                  67.500
38                 10.499          0.935                  67.906
39                 10.576          0.802                  73.898
40                 10.481          0.941                  68.800
41                 10.350          0.896                  69.652
42                  8.836          0.918                  65.255
43                 10.071          0.882                  70.000
44                 10.382          0.898                  69.702
45                 10.155          0.952                  65.200
46                 10.284          0.832                  67.355
47                 10.817          0.843                  66.900
48                  9.787          0.873                  68.600
49                  9.054          0.762                  66.402
50                 10.008          0.905                  66.701
51                 10.315          0.927                  67.100
52                  9.557          0.847                  68.001
53                 10.358          0.943                  68.000
54                  9.805          0.888                  67.401
55                  8.620          0.864                  67.657
56                 10.611          0.884                  75.100
57                  9.962          0.898                  69.000
58                 10.421          0.879                  72.600
59                  8.648          0.812                  67.300
60                 10.217          0.924                  70.799
61                  9.076          0.830                  62.000
62                 10.651          0.799                  73.900
63                  9.458          0.832                  68.250
64                  9.590          0.870                  68.098
65                  9.454          0.857                  65.699
66                  9.313          0.821                  68.800
67                  8.538          0.893                  64.401
68                 10.279          0.823                  72.600
69                  9.046          0.810                  63.901
70                  9.400          0.935                  62.500
71                  9.448          0.893                  65.900
72                  9.940          0.858                  68.699
73                  9.802          0.853                  66.102
74                 10.576          0.820                  73.898
75                  9.853          0.910                  66.253
76                 10.189          0.903                  64.703
77                 11.000          0.836                  76.820
78                  8.091          0.860                  64.281
79                  8.973          0.850                  68.034
80                  9.622          0.827                  62.300
81                 10.238          0.817                  67.102
82                  9.365          0.811                  62.236
83                  8.117          0.636                  58.221
84                  9.673          0.811                  69.593
85                  8.551          0.644                  50.114
86                  9.487          0.799                  67.055
87                  8.120          0.774                  64.233
88                 10.016          0.931                  67.000
89                  9.826          0.913                  70.600
90                  9.569          0.836                  65.656
91                  8.189          0.710                  53.515
92                  8.118          0.710                  59.802
93                  9.520          0.697                  68.999
94                  9.693          0.805                  65.474
95                  8.580          0.727                  57.586
96                  7.098          0.641                  53.780
97                  9.629          0.983                  62.409
98                  7.686          0.690                  55.160
99                  8.087          0.489                  54.713
100                 8.947          0.728                  58.968
101                 8.454          0.693                  64.800
102                 7.838          0.639                  55.008
103                 9.403          0.860                  56.904
104                10.240          0.822                  67.199
105                 8.458          0.651                  58.709
106                 8.903          0.560                  66.208
107                 9.073          0.861                  66.700
108                 9.585          0.671                  64.300
109                 9.342          0.802                  66.005
110                 9.436          0.888                  64.902
111                 9.240          0.746                  60.583
112                 9.603          0.776                  59.962
113                 7.678          0.672                  54.151
114                 8.360          0.765                  62.000
115                 7.158          0.744                  54.706
116                 8.533          0.740                  50.102
117                 7.744          0.724                  51.969
118                 9.584          0.710                  66.300
119                 7.677          0.781                  56.101
120                 7.288          0.720                  56.498
121                 8.361          0.688                  60.704
122                 9.266          0.691                  67.201
123                 9.626          0.848                  67.355
124                 9.161          0.818                  56.799
125                 8.485          0.826                  62.250
126                 8.541          0.779                  59.302
127                 9.182          0.767                  67.000
128                 7.364          0.619                  48.478
129                 9.470          0.827                  67.299
130                 9.065          0.770                  50.833
131                 8.031          0.626                  57.349
132                 9.367          0.750                  61.998
133                 7.694          0.764                  59.000
134                 8.542          0.795                  57.161
135                 7.396          0.686                  59.305
136                 7.362          0.569                  54.914
137                 8.145          0.708                  55.809
138                 7.434          0.630                  51.651
139                 8.755          0.603                  60.633
140                 6.635          0.490                  53.400
141                 7.578          0.832                  57.122
142                 7.876          0.702                  57.999
143                 7.477          0.540                  55.700
144                 6.958          0.537                  57.948
145                 7.926          0.787                  48.700
146                 9.782          0.784                  59.269
147                 7.676          0.552                  61.400
148                 7.943          0.750                  56.201
149                 7.695          0.463                  52.493
    Freedom To Make Life Choices Generosity Perceptions.of.corruption
1                          0.949     -0.098                     0.186
2                          0.946      0.030                     0.179
3                          0.919      0.025                     0.292
4                          0.955      0.160                     0.673
5                          0.913      0.175                     0.338
6                          0.960      0.093                     0.270
7                          0.945      0.086                     0.237
8                          0.907     -0.034                     0.386
9                          0.929      0.134                     0.242
10                         0.908      0.042                     0.481
11                         0.914      0.159                     0.442
12                         0.800      0.031                     0.753
13                         0.875      0.011                     0.460
14                         0.915      0.089                     0.415
15                         0.879      0.077                     0.363
16                         0.934     -0.126                     0.809
17                         0.859      0.233                     0.459
18                         0.858     -0.208                     0.868
19                         0.837      0.098                     0.698
20                         0.783     -0.153                     0.646
21                         0.822     -0.147                     0.571
22                         0.925      0.089                     0.722
23                         0.927      0.133                     0.653
24                         0.784     -0.070                     0.721
25                         0.932      0.074                     0.589
26                         0.877     -0.149                     0.684
27                         0.761     -0.081                     0.745
28                         0.693     -0.084                     0.866
29                         0.949     -0.101                     0.806
30                         0.906     -0.038                     0.775
31                         0.896     -0.092                     0.590
32                         0.927     -0.018                     0.082
33                         0.869      0.257                     0.917
34                         0.766     -0.124                     0.911
35                         0.804     -0.071                     0.756
36                         0.862     -0.147                     0.799
37                         0.890     -0.137                     0.884
38                         0.773     -0.203                     0.826
39                         0.763     -0.015                     0.844
40                         0.909     -0.106                     0.527
41                         0.872     -0.166                     0.856
42                         0.970      0.311                     0.515
43                         0.742     -0.044                     0.830
44                         0.841     -0.165                     0.735
45                         0.853     -0.069                     0.733
46                         0.845     -0.219                     0.938
47                         0.867     -0.104                     0.736
48                         0.778      0.002                     0.835
49                         0.888     -0.110                     0.688
50                         0.867     -0.054                     0.789
51                         0.715     -0.162                     0.800
52                         0.837     -0.135                     0.841
53                         0.755     -0.186                     0.876
54                         0.884      0.287                     0.895
55                         0.836      0.020                     0.664
56                         0.796     -0.258                     0.638
57                         0.828     -0.182                     0.834
58                         0.892     -0.244                     0.887
59                         0.857      0.081                     0.809
60                         0.754     -0.118                     0.939
61                         0.917     -0.097                     0.742
62                         0.672     -0.083                     0.727
63                         0.822     -0.154                     0.891
64                         0.706      0.113                     0.931
65                         0.822     -0.079                     0.918
66                         0.842     -0.124                     0.843
67                         0.935      0.119                     0.908
68                         0.582     -0.288                     0.823
69                         0.875     -0.077                     0.839
70                         0.708      0.116                     0.856
71                         0.876      0.028                     0.882
72                         0.708     -0.034                     0.812
73                         0.860     -0.133                     0.714
74                         0.795      0.012                     0.626
75                         0.650     -0.180                     0.627
76                         0.718     -0.111                     0.845
77                         0.717      0.067                     0.403
78                         0.832     -0.056                     0.553
79                         0.940     -0.098                     0.796
80                         0.771     -0.087                     0.667
81                         0.895      0.125                     0.839
82                         0.873      0.542                     0.867
83                         0.695     -0.068                     0.745
84                         0.904     -0.146                     0.755
85                         0.741     -0.016                     0.794
86                         0.825     -0.168                     0.629
87                         0.782      0.152                     0.727
88                         0.788     -0.096                     0.932
89                         0.854      0.024                     0.825
90                         0.814     -0.223                     0.506
91                         0.731      0.026                     0.848
92                         0.695     -0.046                     0.801
93                         0.785     -0.030                     0.901
94                         0.751      0.038                     0.905
95                         0.807      0.123                     0.848
96                         0.806      0.018                     0.693
97                         0.877      0.273                     0.888
98                         0.697      0.424                     0.746
99                         0.757     -0.034                     0.661
100                        0.910      0.123                     0.658
101                        0.877     -0.041                     0.682
102                        0.697      0.095                     0.766
103                        0.749     -0.067                     0.860
104                        0.576     -0.139                     0.776
105                        0.726      0.098                     0.787
106                        0.774     -0.236                     0.801
107                        0.615     -0.169                     0.827
108                        0.783     -0.238                     0.655
109                        0.480     -0.067                     0.752
110                        0.724     -0.011                     0.924
111                        0.630     -0.053                     0.875
112                        0.731     -0.200                     0.840
113                        0.695     -0.009                     0.748
114                        0.959      0.034                     0.843
115                        0.882      0.061                     0.684
116                        0.737      0.037                     0.878
117                        0.697     -0.036                     0.827
118                        0.608      0.218                     0.714
119                        0.709      0.122                     0.855
120                        0.735      0.050                     0.850
121                        0.779      0.287                     0.825
122                        0.656     -0.201                     0.870
123                        0.525     -0.073                     0.898
124                        0.719     -0.149                     0.847
125                        0.653     -0.163                     0.821
126                        0.876      0.509                     0.660
127                        0.755     -0.167                     0.705
128                        0.579      0.041                     0.807
129                        0.841      0.079                     0.863
130                        0.647     -0.185                     0.708
131                        0.548      0.082                     0.781
132                        0.749     -0.182                     0.795
133                        0.752      0.082                     0.761
134                        0.561     -0.106                     0.731
135                        0.552     -0.005                     0.803
136                        0.619      0.032                     0.772
137                        0.782      0.061                     0.823
138                        0.717      0.084                     0.866
139                        0.893      0.089                     0.774
140                        0.626     -0.024                     0.607
141                        0.602     -0.147                     0.800
142                        0.833      0.183                     0.577
143                        0.593      0.422                     0.721
144                        0.780      0.038                     0.729
145                        0.715     -0.131                     0.915
146                        0.824     -0.246                     0.801
147                        0.897      0.061                     0.167
148                        0.677     -0.047                     0.821
149                        0.382     -0.102                     0.924
    Ladder.score.in.Dystopia Dystopia...residual
1                       2.43               3.253
2                       2.43               2.868
3                       2.43               2.839
4                       2.43               2.967
5                       2.43               2.798
6                       2.43               2.580
7                       2.43               2.683
8                       2.43               2.653
9                       2.43               2.612
10                      2.43               2.784
11                      2.43               2.598
12                      2.43               3.083
13                      2.43               2.824
14                      2.43               2.585
15                      2.43               2.384
16                      2.43               3.387
17                      2.43               2.596
18                      2.43               3.124
19                      2.43               2.807
20                      2.43               2.862
21                      2.43               2.521
22                      2.43               2.631
23                      2.43               2.268
24                      2.43               2.687
25                      2.43               2.422
26                      2.43               2.668
27                      2.43               2.513
28                      2.43               2.794
29                      2.43               2.388
30                      2.43               3.375
31                      2.43               2.600
32                      2.43               1.379
33                      2.43               3.182
34                      2.43               2.714
35                      2.43               3.015
36                      2.43               2.961
37                      2.43               3.135
38                      2.43               2.624
39                      2.43               2.578
40                      2.43               2.103
41                      2.43               2.509
42                      2.43               2.477
43                      2.43               2.682
44                      2.43               2.438
45                      2.43               2.446
46                      2.43               2.830
47                      2.43               2.368
48                      2.43               2.682
49                      2.43               3.085
50                      2.43               2.462
51                      2.43               2.536
52                      2.43               2.794
53                      2.43               2.432
54                      2.43               2.309
55                      2.43               2.841
56                      2.43               2.048
57                      2.43               2.461
58                      2.43               2.225
59                      2.43               2.934
60                      2.43               2.325
61                      2.43               2.872
62                      2.43               2.262
63                      2.43               2.744
64                      2.43               2.583
65                      2.43               2.665
66                      2.43               2.653
67                      2.43               2.648
68                      2.43               2.561
69                      2.43               2.805
70                      2.43               2.492
71                      2.43               2.306
72                      2.43               2.254
73                      2.43               2.178
74                      2.43               1.653
75                      2.43               2.247
76                      2.43               2.148
77                      2.43               1.236
78                      2.43               2.619
79                      2.43               2.211
80                      2.43               2.331
81                      2.43               1.784
82                      2.43               1.987
83                      2.43               3.476
84                      2.43               1.982
85                      2.43               3.469
86                      2.43               2.127
87                      2.43               2.642
88                      2.43               1.823
89                      2.43               1.520
90                      2.43               1.919
91                      2.43               3.195
92                      2.43               3.071
93                      2.43               2.250
94                      2.43               2.042
95                      2.43               2.684
96                      2.43               3.470
97                      2.43               1.409
98                      2.43               2.990
99                      2.43               3.482
100                     2.43               2.204
101                     2.43               2.427
102                     2.43               3.216
103                     2.43               2.187
104                     2.43               1.852
105                     2.43               2.784
106                     2.43               2.749
107                     2.43               2.135
108                     2.43               2.191
109                     2.43               2.242
110                     2.43               1.813
111                     2.43               2.429
112                     2.43               2.201
113                     2.43               3.133
114                     2.43               2.148
115                     2.43               2.783
116                     2.43               2.736
117                     2.43               3.016
118                     2.43               1.823
119                     2.43               2.596
120                     2.43               2.857
121                     2.43               2.180
122                     2.43               2.138
123                     2.43               1.736
124                     2.43               2.068
125                     2.43               2.131
126                     2.43               1.407
127                     2.43               1.553
128                     2.43               3.209
129                     2.43               1.075
130                     2.43               2.155
131                     2.43               2.610
132                     2.43               1.648
133                     2.43               2.089
134                     2.43               2.069
135                     2.43               2.620
136                     2.43               2.806
137                     2.43               1.975
138                     2.43               2.396
139                     2.43               1.405
140                     2.43               2.876
141                     2.43               1.776
142                     2.43               1.263
143                     2.43               2.060
144                     2.43               2.190
145                     2.43               1.800
146                     2.43               0.648
147                     2.43               1.095
148                     2.43               1.205
149                     2.43               1.895
  • Obtaining a frequency table using the janitor package

    To understand the distribution of observations across different regions, providing an overview of how data is distributed among different categories.

frequency_table <- janitor::tabyl(renamed_dataset, Region)

print(frequency_table)
                             Region  n    percent
         Central and Eastern Europe 17 0.11409396
 Commonwealth of Independent States 12 0.08053691
                          East Asia  6 0.04026846
        Latin America and Caribbean 20 0.13422819
       Middle East and North Africa 17 0.11409396
              North America and ANZ  4 0.02684564
                         South Asia  7 0.04697987
                     Southeast Asia  9 0.06040268
                 Sub-Saharan Africa 36 0.24161074
                     Western Europe 21 0.14093960
  • Calculate mean happiness score and social support by region

    To summarize and analyze the average happiness score and social support within each region, enabling comparison and identification of regional trends.

summary_data <- renamed_dataset %>%
  group_by(Region) %>%
  summarise(mean_happiness_score = mean(`Happiness Score`),
            mean_social_support = mean(`Social.support`))
  • Creating a new variable to represent the economic freedom score, happiness index, health index and using mutation function providing additional insights and facilitating further analysis of the dataset.
mutated_dataset <- renamed_dataset %>%
  mutate(
    Economic_Freedom_Score = `Logged.GDP.per.capita` * `Freedom To Make Life Choices`,
    Happiness_Index = `Happiness Score` / max(`Happiness Score`),
    Health_Index = (`Social.support` + `Healthy.life.expectancy`) / 2
  )

Forcats Package

Applying fct_rev

Utilization of fct_rev to reverse the order of factor levels within the categorical variable “Region”. By reversing the factor levels, we can highlight different regions characteristics.

renamed_dataset <- renamed_dataset %>%
  mutate(Region = factor(Region))
renamed_dataset <- renamed_dataset %>%
  mutate(Region = fct_rev(Region))
levels(renamed_dataset$Region)
 [1] "Western Europe"                     "Sub-Saharan Africa"                
 [3] "Southeast Asia"                     "South Asia"                        
 [5] "North America and ANZ"              "Middle East and North Africa"      
 [7] "Latin America and Caribbean"        "East Asia"                         
 [9] "Commonwealth of Independent States" "Central and Eastern Europe"        

Reorder levels of Region based on median Happiness Score

Utilization of fct_reorder was to reorder the levels of the “region” variable based on the median “Happiness score”. By prioritizing regions with higher median happiness scores, we can emphasize the importance of understanding the factors contributing to well-being in these regions.

renamed_dataset <- renamed_dataset %>%
  mutate(Region = fct_reorder(Region, `Happiness Score`, .fun = median))
levels(renamed_dataset$Region)
 [1] "Sub-Saharan Africa"                 "Middle East and North Africa"      
 [3] "South Asia"                         "Southeast Asia"                    
 [5] "Commonwealth of Independent States" "East Asia"                         
 [7] "Latin America and Caribbean"        "Central and Eastern Europe"        
 [9] "Western Europe"                     "North America and ANZ"