Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The UN has published the World Happiness Report from 2012 and this original visualisation is presented in the 4th report of 2016. The World Happiness Report 2016 includes the happiness scores evaluated by 7 factors, economic (GDP per Capita), family, health (life expectancy), freedom, generosity, trust (government Corruption) and Dystopia residual, in 156 countries. Although this visualisation shows 21 western European countries.
This happiness index and subjective well-being including 7 attributes can be used as key indicators of the quality of human development. In addition, health organization, governments and local communities are able to implement new policies for people to live a better life by utilising the world happiness reports.
The visualisation chosen had the following three main issues:
Reference
The following code was used to fix the issues identified in the original.
setwd("D:/RMIT/2021_1st semester/MATH2270 Data Visualisation & Comm/Assignment/Assignment2")
library(ggplot2)
library(dplyr)
library(tidyr)
library(forcats)
library(extrafont)
Happiness<-read.csv("2016.csv")
West_EU<-Happiness%>%filter(Region=='Western Europe')
head(West_EU)
## Country Region Happiness.Rank Happiness.Score
## 1 Denmark Western Europe 1 7.526
## 2 Switzerland Western Europe 2 7.509
## 3 Iceland Western Europe 3 7.501
## 4 Norway Western Europe 4 7.498
## 5 Finland Western Europe 5 7.413
## 6 Netherlands Western Europe 7 7.339
## Lower.Confidence.Interval Upper.Confidence.Interval Economy..GDP.per.Capita.
## 1 7.460 7.592 1.44178
## 2 7.428 7.590 1.52733
## 3 7.333 7.669 1.42666
## 4 7.421 7.575 1.57744
## 5 7.351 7.475 1.40598
## 6 7.284 7.394 1.46468
## Family Health..Life.Expectancy. Freedom Trust..Government.Corruption.
## 1 1.16374 0.79504 0.57941 0.44453
## 2 1.14524 0.86303 0.58557 0.41203
## 3 1.18326 0.86733 0.56624 0.14975
## 4 1.12690 0.79579 0.59609 0.35776
## 5 1.13464 0.81091 0.57104 0.41004
## 6 1.02912 0.81231 0.55211 0.29927
## Generosity Dystopia.Residual
## 1 0.36171 2.73939
## 2 0.28083 2.69463
## 3 0.47678 2.83137
## 4 0.37895 2.66465
## 5 0.25492 2.82596
## 6 0.47416 2.70749
colnames(West_EU)
## [1] "Country" "Region"
## [3] "Happiness.Rank" "Happiness.Score"
## [5] "Lower.Confidence.Interval" "Upper.Confidence.Interval"
## [7] "Economy..GDP.per.Capita." "Family"
## [9] "Health..Life.Expectancy." "Freedom"
## [11] "Trust..Government.Corruption." "Generosity"
## [13] "Dystopia.Residual"
west_EU<-West_EU[,-which(names(West_EU) %in% c("Region","Happiness.Score","Lower.Confidence.Interval","Upper.Confidence.Interval"))]
colnames(west_EU)
## [1] "Country" "Happiness.Rank"
## [3] "Economy..GDP.per.Capita." "Family"
## [5] "Health..Life.Expectancy." "Freedom"
## [7] "Trust..Government.Corruption." "Generosity"
## [9] "Dystopia.Residual"
country<-west_EU[c(order(-west_EU$Happiness.Rank, decreasing=FALSE)),]
country<-country$Country
west_EU<-gather(west_EU, "Attribute", "Score", 3:9)
west_EU<-west_EU[c(order(-west_EU$Happiness.Rank, decreasing=FALSE)),]
table(west_EU$Attribute)
##
## Dystopia.Residual Economy..GDP.per.Capita.
## 21 21
## Family Freedom
## 21 21
## Generosity Health..Life.Expectancy.
## 21 21
## Trust..Government.Corruption.
## 21
west_EU$Attribute<-fct_collapse(west_EU$Attribute,
Dystopia_Residual="Dystopia.Residual",
Economy="Economy..GDP.per.Capita.",
Family="Family",
Freedom="Freedom",
Generosity="Generosity",
Health="Health..Life.Expectancy.",
Trust="Trust..Government.Corruption.")
west_EU$Country<-factor(west_EU$Country,levels=country)
west_EU$Country<-fct_collapse(west_EU$Country,
UK="United Kingdom")
g<-ggplot(west_EU,aes(x=Country, y=Score))
g1<-g+geom_col(aes(fill=Attribute), width=0.7, colour="black")+
geom_text(aes(label=Happiness.Rank, y=0),
fill="grey", hjust="top", family="Arial")+
coord_flip()
background <- "#EFF1F0"
pal <- c("#A7CECB",
"#8BA6A9",
"#75704E",
"#CACC90",
"#F4EBBE",
"#FDE74C",
"#D7907B"
)
g2<-g1+theme_gray() +
scale_fill_manual(values = pal) +
theme(plot.background = element_rect(fill = background),
panel.background = element_rect(fill = background),
legend.background = element_rect(fill = background),
text=element_text(family="Arial"),
title = element_text(face = "bold"))
g2<-g2+labs(x="Country", y="Happiness score",
title="Happiness score of western European countries by attribute",
caption="Source: World Happiness Report (2016)")
Data Reference
The following plot fixes the main issues in the original.