knitr::opts_chunk$set(fig.width=12, fig.height=8)
Loading Librares and Data
library(ggalt)
library(dplyr)
library(gridExtra)
data2015<-read.csv("C:/Users/power/BST260/Project/BST260_ClassProject/year14.csv",header=T)
data2019<-read.csv("C:/Users/power/BST260/Project/BST260_ClassProject/year18.csv",header=T)
In this session, two years (2014 and 2018) data are listed and discussed. For Asia in 2014, Israel had the highest value of 7.28 And the next two highest values came from United Arab emirates (6.90) and Sigapore (6.80).Afghanistan (3.58) and Syria(3.01) had the lowest two values of happiness score. These two countries have been involved with many conflicts/wars for many years. In 2018, Isreal, UAE and Taiwan had the highest values, and Syria, Yemen amd Afghanistan had the lowest values. It is interesting that Combodian jumped from the last three in 2014 (3.82) to the last 13 in 2018 (4.70), which is the lagest transformation in Asia.However, Yeman plummetted from the last four (4.08) to the last two (3.38).
####2014 Happiness score {.tabset}
asiad15<-data2015 %>% select(Country,Continent,HS15=HScore)%>%filter(Continent=="Asia")
asiad19<-data2019 %>% select(Country,Continent,HS19=HScore)%>%filter(Continent=="Asia")
score<-inner_join(asiad15,asiad19)%>% mutate(score_diff= HS19-HS15)
score2<-na.omit(score)
score2 <- score2[order(score2$HS15), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p1<-ggplot(score2, aes(x=reorder(`Country`,-HS15), y=HS15, label=sprintf("%0.2f",round(HS15,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS15,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014")+
coord_flip()
###2018 Happiness score {.tabset}
score2 <- score2[order(score2$HS19), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p2<-ggplot(score2, aes(x=reorder(`Country`,-HS19),y=HS19, label=sprintf("%0.2f",round(HS19,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS19,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2018")+
coord_flip()
score2 <- score2[order(score2$score_diff), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
library(ggplot2)
theme_set(theme_bw())
p3<-ggplot(score2, aes(x=reorder(`Country`,-score_diff), y=score_diff, label=sprintf("%0.2f",round(score_diff,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = score_diff,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014 vs 2018") +
ylim(-1, 1) +
coord_flip()
grid.arrange(p1, p2, p3, ncol = 3)
For Europe, all are higher than many countries in other continents. In 2014, Switzerland, Iceland, Demark, and Norway had the values more than 7.5. Albania, Bosnia, Greece, Hungary, Ukrainie, and Bulgaria had the lowest values. All are East European countries. Espeically, Crimea of Ukrainie was seized by Russia in 2014. In 2018, Finland was the highest one with the value of 7.7, and the next two are Denmark and Norway. All are North European countries. Hungary had the largest jump from 4.8 to 5.76. Romania and Lativia had higher transformation as well. However, Ukrainie became the lowest one in 2018.
####2014 Happiness score {.tabset}
Eur15<-data2015 %>% select(Country,Continent,HS15=HScore)%>%filter(Continent=="Europe")
Eur19<-data2019 %>% select(Country,Continent,HS19=HScore)%>%filter(Continent=="Europe")
score<-inner_join(Eur15,Eur19)%>% mutate(score_diff= HS19-HS15)
score2<-na.omit(score)
score2 <- score2[order(score2$HS15), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p1<-ggplot(score2, aes(x=reorder(`Country`,-HS15), y=HS15, label=sprintf("%0.2f",round(HS15,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS15,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014")+
coord_flip()
###2018 Happiness score {.tabset}
score2 <- score2[order(score2$HS19), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p2<-ggplot(score2, aes(x=reorder(`Country`,-HS19),y=HS19, label=sprintf("%0.2f",round(HS19,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS19,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2018")+
coord_flip()
score2 <- score2[order(score2$score_diff), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
library(ggplot2)
theme_set(theme_bw())
p3<-ggplot(score2, aes(x=reorder(`Country`,-score_diff), y=score_diff, label=sprintf("%0.2f",round(score_diff,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = score_diff,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014 vs 2018") +
ylim(-1, 1) +
coord_flip()
grid.arrange(p1, p2, p3, ncol = 3)
In both two years, Canada and Cosat Rica had the highest happiness socre. Haiti had the lowest values in these two years.Honduras had the higehst transformation value from 4.79 in 2014 to 5.86 in 2018. United States decreased with 0.23. Dominican Republic, Honduras and Haiti were the three countries with the lowest values in these two years.
####2014 Happiness score {.tabset}
NA15<-data2015 %>% select(Country,Continent,HS15=HScore)%>%filter(Continent=="North America")
NA19<-data2019 %>% select(Country,Continent,HS19=HScore)%>%filter(Continent=="North America")
score<-inner_join(NA15,NA19)%>% mutate(score_diff= HS19-HS15)
score2<-na.omit(score)
score2 <- score2[order(score2$HS15), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p1<-ggplot(score2, aes(x=reorder(`Country`,-HS15), y=HS15, label=sprintf("%0.2f",round(HS15,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS15,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014")+
coord_flip()
###2018 Happiness score {.tabset}
score2 <- score2[order(score2$HS19), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p2<-ggplot(score2, aes(x=reorder(`Country`,-HS19),y=HS19, label=sprintf("%0.2f",round(HS19,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS19,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2018")+
coord_flip()
score2 <- score2[order(score2$score_diff), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
library(ggplot2)
theme_set(theme_bw())
p3<-ggplot(score2, aes(x=reorder(`Country`,-score_diff), y=score_diff, label=sprintf("%0.2f",round(score_diff,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = score_diff,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014 vs 2018") +
ylim(-1, 1) +
coord_flip()
grid.arrange(p1, p2, p3, ncol = 3)
Brazil had the largest value of 6.98 in 2014 and the second largest value of 6.30 in 2018.Venezula had the largest decrease from the second highest plance in 2014 to the bottom in 2018. In 2014, Venezuela entered an economic recession having its GDP growth decline to −3.0%. The Economist said Venezuela was “probably the world’s worst-managed economy”. Suprisely, happiness socres of South America decreased from 2014 to 2018. recession heavily impacted the life there.
####2014 Happiness score {.tabset}
SA15<-data2015 %>% select(Country,Continent,HS15=HScore)%>%filter(Continent=="South America")
SA19<-data2019 %>% select(Country,Continent,HS19=HScore)%>%filter(Continent=="South America")
score<-inner_join(SA15,SA19)%>% mutate(score_diff= HS19-HS15)
score2<-na.omit(score)
score2 <- score2[order(score2$HS15), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p1<-ggplot(score2, aes(x=reorder(`Country`,-HS15), y=HS15, label=sprintf("%0.2f",round(HS15,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS15,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014")+
coord_flip()
###2018 Happiness score {.tabset}
score2 <- score2[order(score2$HS19), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p2<-ggplot(score2, aes(x=reorder(`Country`,-HS19),y=HS19, label=sprintf("%0.2f",round(HS19,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS19,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2018")+
coord_flip()
score2 <- score2[order(score2$score_diff), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
library(ggplot2)
theme_set(theme_bw())
p3<-ggplot(score2, aes(x=reorder(`Country`,-score_diff), y=score_diff, label=sprintf("%0.2f",round(score_diff,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = score_diff,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014 vs 2018") +
ylim(-1, 1) +
coord_flip()
grid.arrange(p1, p2, p3, ncol = 3)
Only three Oceanian countries are analyzed in this study. Australia and New Zealnad did not make any big changes in these two years.
####2014 Happiness score {.tabset}
Oceania15<-data2015 %>% select(Country,Continent,HS15=HScore)%>%filter(Continent=="Oceania")
Oceania19<-data2019 %>% select(Country,Continent,HS19=HScore)%>%filter(Continent=="Oceania")
score<-inner_join(Oceania15,Oceania19)%>% mutate(score_diff= HS19-HS15)
score2<-na.omit(score)
score2 <- score2[order(score2$HS15), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p1<-ggplot(score2, aes(x=reorder(`Country`,-HS15), y=HS15, label=sprintf("%0.2f",round(HS15,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS15,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014")+
coord_flip()
###2018 Happiness score {.tabset}
score2 <- score2[order(score2$HS19), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p2<-ggplot(score2, aes(x=reorder(`Country`,-HS19),y=HS19, label=sprintf("%0.2f",round(HS19,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS19,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2018")+
coord_flip()
score2 <- score2[order(score2$score_diff), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
library(ggplot2)
theme_set(theme_bw())
p3<-ggplot(score2, aes(x=reorder(`Country`,-score_diff), y=score_diff, label=sprintf("%0.2f",round(score_diff,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = score_diff,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014 vs 2018") +
ylim(-1, 1) +
coord_flip()
grid.arrange(p1, p2, p3, ncol = 3)
Most African countries had the relative lower happiness countries compared with other continenets. Ecuador had the highest values in both 2014 (5.9) and 2018 (6.0). Togo had the lowest one of 2.84 in 2014 but it jumped to 4.08 in 2018. Central African Republic decreased from 3.68 to 3.08 as the lowest place in 2018. These two sections focused on the data in a static way. The next session formulats the tranfromation through the five years.
####2014 Happiness score {.tabset}
Africa15<-data2015 %>% select(Country,Continent,HS15=HScore)%>%filter(Continent=="Africa")
Africa19<-data2019 %>% select(Country,Continent,HS19=HScore)%>%filter(Continent=="Africa")
score<-inner_join(Africa15,Africa19)%>% mutate(score_diff= HS19-HS15)
score2<-na.omit(score)
score2 <- score2[order(score2$HS15), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p1<-ggplot(score2, aes(x=reorder(`Country`,-HS15), y=HS15, label=sprintf("%0.2f",round(HS15,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS15,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014")+
coord_flip()
###2018 Happiness score {.tabset}
score2 <- score2[order(score2$HS19), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
theme_set(theme_bw())
p2<-ggplot(score2, aes(x=reorder(`Country`,-HS19),y=HS19, label=sprintf("%0.2f",round(HS19,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = HS19,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2018")+
coord_flip()
score2 <- score2[order(score2$score_diff), ] # sort
score2$Country <- factor(score2$Country, levels = score2$Country)
library(ggplot2)
theme_set(theme_bw())
p3<-ggplot(score2, aes(x=reorder(`Country`,-score_diff), y=score_diff, label=sprintf("%0.2f",round(score_diff,digit=2)))) +
#geom_point() +
geom_segment(aes(y = 0,
x = `Country`,
yend = score_diff,
xend = `Country`),
color = "blue") +
geom_text(color="black", size=2) +
labs(title="Happiness Score: 2014 vs 2018") +
ylim(-1, 1) +
coord_flip()
grid.arrange(p1, p2, p3, ncol = 3)