To better show the association of other factors and happiness score, we standardize the value of other factors by subtracting mean and dividing standard error. This is because the scale of gdp and life_expectancy are dramatically different from other factors.
happy = read_csv("data/happy.csv")
happy_standard = happy %>%
mutate(s_gdp = scale(gdp),
s_social_support = scale(social_support),
s_life_expectance = scale(life_expectance),
s_freedom = scale(freedom),
s_positive_affect = scale(positive_affect),
s_negative_affect = scale(negative_affect),
s_generosity = scale(generosity),
s_corruption = scale(corruption)) %>%
select(-c(gdp:corruption), -o_gdp)
plot1 = happy %>%
group_by(year) %>%
summarise(year_mean_score = mean(happiness_score)) %>%
ggplot(aes(x = year, y = year_mean_score)) +
geom_path() +
labs(title = "Happiness score changes worldwide: 2007-2018",
x = "Year",
y = "Happiness score") +
scale_x_continuous(
breaks = c(2007,2008,2009,2010,2011, 2012, 2013,2014,2015,2016,2017,2018))
plot1+transition_reveal(year)

From the first plot, we can easily find that the mean happiness score increases from 2007 to 2010, and gradually decreases to the lowest point in 2014. Finally, it increases in recent years.
plot2 = happy %>%
group_by(year, continent) %>%
summarise(year_mean_score = mean(happiness_score)) %>%
ggplot(aes(x = year, y = year_mean_score, color = continent)) +
geom_point() +
geom_line() +
geom_smooth(method = lm, size = 0.5,
se = FALSE, color = "red") +
facet_grid(. ~ continent) +
labs(title = "Happiness score changes in various continent: 2007-2018",
x = "Year",
y = "Happiness score") +
theme(legend.position = "none")
plot3 = happy %>%
drop_na(develop) %>%
group_by(year, develop) %>%
summarise(year_mean_score = mean(happiness_score)) %>%
ggplot(aes(x = year, y = year_mean_score, color = develop)) +
geom_point() +
geom_line() +
geom_smooth(method = lm, size = 0.5,
se = FALSE, color = "red") +
facet_grid(. ~ develop) +
labs(title = "Happiness score changes in developed and developing countries: 2007-2018",
x = "Year",
y = "Happiness score")+
theme(legend.position = "none")
plot2/plot3

From the second plot, we divide these countries into different regions by the geographic continent. Australia has the overall highest and Africa has the overall lowest happiness score. Only Europe and Asia show the general increasing trend of happiness score over time.
We can roughly further divide these continents into three groups base on the happiness scores. The high happiness score group contains Australis, the medium happiness score group contains Europe, North America and South America, and the low happiness score group contains Africa and Asia.
From the third plot, the mean happiness score is obviously higher in developed countries than it in developing countries.
happy_standard %>%
pivot_longer(s_gdp:s_corruption,
names_to = "standard_factors",
values_to = "standard_value") %>%
ggplot(aes(x = happiness_score, y = standard_value,
color = standard_factors)) +
geom_point() +
geom_boxplot(alpha = .8) +
geom_smooth(method = lm, color = "red") +
facet_grid(. ~ standard_factors) +
labs(x = "Happiness score",
y = "Standard score of other factors",
title = "Happiness score against other factors worldwide: 2007-2018") +
theme(legend.position = "none")

happy %>%
drop_na() %>%
select(-c(country, year, continent, develop,o_gdp)) %>%
cor() %>%
corrplot.mixed(title = "Happiness score against other factors worldwide: 2007-2018",
tl.cex = 1.2, tl.pos = "lt", number.cex = 1.2,
mar = c(0,0,1,0))

From the scatterplot, the factors negative_affect and corruption have the negative association with happiness score, but gdp, social support, life_expectancy, freedom, positive_affect and generosity have the positive association.
From the correlation matrix plot, the happiness score is highly associated with gdp, social_support and life_expectancy(> 0.7). In addition, gdp and life_expctancy are highly correlated with each other(> 0.7).
happy %>%
drop_na() %>%
filter(continent == "Australia") %>%
select(-c(country, year, continent, develop,o_gdp)) %>%
cor() %>%
corrplot.mixed(title = "Australia: 2007-2018",
tl.cex = 1.2, tl.pos = "lt", number.cex = 1.2,
mar=c(0,0,1,0))

happy %>%
drop_na() %>%
filter(continent %in% c("Europe", "North America", "South America")) %>%
select(-c(country, year, continent, develop,o_gdp)) %>%
cor() %>%
corrplot.mixed(title = "Europe, North America, South America: 2007-2018",
tl.cex = 1.2, tl.pos = "lt", number.cex = 1.2,
mar = c(0,0,1,0))

happy %>%
drop_na() %>%
filter(continent %in% c("Africa", "Asia")) %>%
select(-c(country, year, continent, develop,o_gdp)) %>%
cor() %>%
corrplot.mixed(title = "Africa, Asia: 2007-2018 ",
tl.cex = 1.2, tl.pos = "lt", number.cex = 1.2,
mar=c(0,0,1,0))

Australia has the highest happiness score, and the score does not have a high correlation with other factors(not greater than 0.4). gdp is strongly positively associated with corruption(0.69) and negatively associated with positive_affe t(-0.86)
Europe, North America, South America have the medium happiness score, and the score has a moderate correlation with gdp, social support, life_expectancy, freedom, positive_affect and corruption(0.6 - 0.7)
Africa and Asia have the lowest happiness score, and the score has a moderate correlation with gdp, social support and life_expectancy(0.6 - 0.7).
happy %>%
drop_na() %>%
filter(develop == "developing") %>%
select(-c( country, year, continent, develop,o_gdp)) %>%
cor() %>%
corrplot.mixed(title = "Developing: 2007-2018",
tl.cex = 1.2, tl.pos = "lt", number.cex = 1.2,
mar=c(0,0,1,0))

happy %>%
drop_na() %>%
filter(develop == "developed") %>%
select(-c(country, year, continent, develop,o_gdp)) %>%
cor() %>%
corrplot.mixed(title = "Developed: 2007-2018",
tl.cex = 1.2, tl.pos = "lt", number.cex = 1.2,
mar=c(0,0,1,0))

Developing countries have lower happiness score, and the score has a moderate correlation with gdp, social support and life_expectancy(around 0.6).
Developed countries have higher happiness score , and the score has a moderate correlation with social support,freedom, positive_affect, negative_affect, generosity and corruption (around 0.6)