There are huge missing data of “happy” which stands how happy are a
person and “netuse”, the personal use of internet/email/www. However,
“happy” has a broader range of values and a wider spread. The median of
netuse is higher then the mean which may show that the majority of
people spending time on internet might not be that nuch, but there are
some relatively high values that are affecting the median, which may
refer that certain amount of people spend lots of time on internet.
“yrbrn” contains no missing data and represents a broad range of birth
years.
ggplot(happy_by_year, aes(x = year, y = mean_happy)) +
geom_line(color = "blue", size = 1) +
geom_point(color = "red", size = 3) +
labs(title = "How happy are you in France (2010-2020)",
x = "Survey Year",
y = "Happy (0-10)") +
ylim(0, 10) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
The mean for the happiness of people in France is quite stable,
continous, since they kept getting the value around 7.5 from 2010 to
2020. And the value is relatively high, compared to the full amount of
value is 10.
Task 3
ess_selected <- ess %>%
filter(cntry %in% c("FR", "DE", "NO")) %>%
mutate(happy = ifelse(happy %in% c(77, 88, 99), NA, happy))
task3plot <- ggplot(ess_selected, aes(x = reorder(cntry, -happy, FUN=median), y = happy, fill = cntry)) +
geom_boxplot() +
theme_minimal() +
theme(legend.position = "none") +
labs(title = "Boxplot comparison for how happy are you (France, Ferman, Norway)",
x = "Country",
y = "Scale (0-10)")
task3plot
The mdeian of France is almost as great as it’s max number, shows on
average, people in France report relatively high happiness levels, and
there might be fewer extremely low happiness scores in the dataset. And
the IQR of the French boxplot is more concentrate, compared to German’s.
This also indicate a more consistent level of happiness among the
population.
For German, the IQR is high compared with the rest of the two
countries, which tells that the population’s happiness scores in Germany
cover a wide range. The median of happiness level of Germanys is
positioned at a high status in the IQR boxplot, so generally, people in
Germany may report higher levels of happiness.
As the boxplot shown by Norway, they have the highest Q1 and Q3
compared with Germany and French, which means people in Norway are
happier than Germans and Frances in a general way. Their median of
happiness level stays around the midpoint in the IQR graph, a balanced
spread of happiness scores. And IQR value is relatively small compared
to Germany, shows that most people in Norway report happiness levels
that are clustered closely together.
The first graph shows the distribution of happiness levels for each
education level, and people who have a bachelor degree seems
happier
The second dataset shows how happiness levels are distributed across
different geographical regions: “Peri-Urban,” “Rural,” “Urban,” and
“All.” Urban and Peri-Urban usually has the higher happy value than
Rural and All.
table(df$happy, df$geo) %>%
cprop() %>%
as.data.frame() %>%
filter(Var1 != "Total",
Var2 != "All") %>%
ggplot(aes(x=Var1, y=Freq, fill=Var2)) +
geom_col(position = "dodge") +
labs(title="How happy are you in France",
y = "Conditional Percentage",
x = "How happy are you",
fill = "Rural vs. Urban vs. Peri-Urban")
france_clean <- france_data %>%
filter(!is.na(geo) & !is.na(happy))
france_probs <- france_clean %>%
count(happy, geo) %>%
group_by(geo) %>%
mutate(prob = n / sum(n))
ggplot(france_probs, aes(x = as.factor(happy), y = prob, color = geo)) +
geom_point() +
geom_line(aes(group = geo)) +
labs(title = "Conditional Probabilities of How Happy Are You",
subtitle = "by Place of Residence",
x = "Happy Scale",
y = "Probability") +
theme_minimal()
In the graph it significantly shows most people in France has a
happy scale of 8, and the peak value is achieved by Peri-Urban people.
Not many people choose they are extremely happy or not happy at all in
all three palces. However according to the general information, it could
tell the scores of happiness level in France is not very happiness
scores, with a very high median.