I will display the ranking data for the Cantril ladder question of WHRdata 2024. In contrast to figure 2.1 of the World Happiness Report 2025 I will use a lollipop plot instead a bar plot. Additionally I will only show the value for the Cantril ladder without the breakdown into its causal components.
cantril_ranking<-function(df){ggplot2::ggplot(df,ggplot2::aes( x =forcats::fct_reorder(`country`, `ladder_score`) , y =`ladder_score`))+ggplot2::geom_segment(ggplot2::aes( x =`country`, xend =`country`, y =1, yend =`ladder_score`), color ="blue")+ggplot2::geom_point(color ="darkblue", size =4)+ggplot2::theme_light()+ggplot2::theme( panel.grid.major.x =ggplot2::element_blank(), panel.border =ggplot2::element_blank(), axis.ticks.x =ggplot2::element_blank(), axis.text.y =ggplot2::element_text(size =20, hjust =0), axis.text.x =ggplot2::element_text(size =20), axis.title.x =ggplot2::element_text(size =20, face ='bold'))+ggplot2::coord_flip()+ggplot2::xlab("")+ggplot2::ylab("Value of life evaluation (3 year average)")}
Code Collection 3.1 : Show value of Cantril ladder by rank
The Cantril Ladder is a visual scale used to assess general life satisfaction. It asks respondents to evaluate their lives on a ladder from worst (bottom) to best (top) possible life, making it a simple tool to measure subjective well-being. This measure has been widely used in various studies and surveys, including the Gallup World Poll, which collects data from over 140 countries annually.
Lollipop plot
A lollipop plot is basically a barplot, where the bar is transformed in a line and a dot. It shows the relationship between a numeric and a categorical variable.
WHR
The World Happiness Reports are a partnership of Gallup, the Oxford Wellbeing Research Centre, the UN Sustainable Development Solutions Network, and the WHR’s Editorial Board. The report is produced under the editorial control of the WHR Editorial Board. The Reports reflects a worldwide demand for more attention to happiness and well-being as criteria for government policy. It reviews the state of happiness in the world today and shows how the science of happiness explains personal and national variations in happiness. (https://worldhappiness.report/about/)
---execute: cache: false---# Ranking 2024 {#sec-03-ranking-2024}```{r}#| label: setup#| results: hold#| include: falsebase::source(file =paste0(here::here(), "/R/helper.R"))```::::: {#obj-chapter-template}:::: {.my-objectives}::: {.my-objectives-header}Objective of this chapter:::::: {.my-objectives-container}I will display the ranking data for the `r glossary("Cantril ladder")` question of `r glossary("WHR")`data 2024. In contrast to figure 2.1 of the World Happiness Report 2025 I will use a `r glossary("lollipop plot")` instead a bar plot. Additionally I will only show the value for the Cantril ladder without the breakdown into its causal components.::::::::::::## Prepare data:::::{.my-r-code}:::{.my-r-code-header}:::::: {#cnj-03-prepare-data}: Prepare 2024 ranking data:::::::::::::{.my-r-code-container}```{r}#| label: prepare-datawhr_final_2024 <- base::readRDS("data/whr-cantril/rds/whr_final.rds") |> dplyr::filter(year ==2024& group48 =="World [WLD]") |> dplyr::arrange(rank) |> dplyr::mutate(`country`= base::paste0(rank, ". ", `country_whr`, " (", `ladder_score`, ")") )my_save_data_file("whr-cantril/rds", whr_final_2024, "whr_final_2024.rds")```<center>(*For this R code chunk is no output available*)</center>:::::::::## Cantril ladder ranking```{r}#| label: cantril-ranking#| results: holdcantril_ranking <-function(df) { ggplot2::ggplot(df, ggplot2::aes(x = forcats::fct_reorder(`country`, `ladder_score`) ,y =`ladder_score` )) + ggplot2::geom_segment(ggplot2::aes(x =`country`,xend =`country`,y =1,yend =`ladder_score` ), color ="blue") + ggplot2::geom_point(color ="darkblue", size =4) + ggplot2::theme_light() + ggplot2::theme(panel.grid.major.x = ggplot2::element_blank(),panel.border = ggplot2::element_blank(),axis.ticks.x = ggplot2::element_blank(),axis.text.y = ggplot2::element_text(size =20, hjust =0),axis.text.x = ggplot2::element_text(size =20),axis.title.x = ggplot2::element_text(size =20, face ='bold') ) + ggplot2::coord_flip() + ggplot2::xlab("") + ggplot2::ylab("Value of life evaluation (3 year average)")}```::: {.my-code-collection}:::: {.my-code-collection-header}::::: {.my-code-collection-icon}::::::::::: {#exm-03-show-ranking-2024}: Show value of Cantril ladder by rank::::::::::::::{.my-code-collection-container}::: {.panel-tabset}###### First part:::::{.my-r-code}:::{.my-r-code-header}:::::: {#cnj-03-show-ranking-2024-first-part}: Show value of Cantril ladder by rank (first part):::::::::::::{.my-r-code-container}```{r}#| label: show-ranking-2024-first-part#| fig-height: 20#| fig-width: 12cantril_ranking(dplyr::slice(whr_final_2024, 1:50))```:::::::::###### Middle part:::::{.my-r-code}:::{.my-r-code-header}:::::: {#cnj-show-ranking-2024-middle-part}: Show value of Cantril ladder by rank (middle part):::::::::::::{.my-r-code-container}```{r}#| label: show-ranking-2024-middle-part#| fig-height: 20#| fig-width: 12cantril_ranking(dplyr::slice(whr_final_2024, 51:100))```:::::::::###### Last part:::::{.my-r-code}:::{.my-r-code-header}:::::: {#cnj-show-ranking-2024-middle-part}: Show value of Cantril ladder by rank (last part):::::::::::::{.my-r-code-container}```{r}#| label: show-ranking-2024-last-part#| fig-height: 20#| fig-width: 12cantril_ranking(dplyr::slice(whr_final_2024, 101:147))```:::::::::###### All together:::::{.my-r-code}:::{.my-r-code-header}:::::: {#cnj-03-show-ranking-2024-all-together}: Show value of Cantril ladder by rank:::::::::::::{.my-r-code-container}```{r}#| label: show-ranking-2024-all-together#| fig-height: 60#| fig-width: 12cantril_ranking(whr_final_2024)```:::::::::::::::::::::## Glossary```{r}#| label: glossary-table#| echo: falseglossary_table()```------------------------------------------------------------------------## Session Info::::: my-r-code::: my-r-code-headerSession Info:::::: my-r-code-container```{r}#| label: session-infosessioninfo::session_info()```::::::::