Import your data
data <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-11-25/spi_indicators.csv')
## Rows: 4340 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): iso3c, country, region, income
## dbl (8): year, population, overall_score, data_use_score, data_services_scor...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data_small <- data %>%
select(country, year, overall_score) %>%
filter (country %in% c("Denmark", "Finland", "Poland")) %>%
filter(year >= 2016)
Separating and Uniting
Unite two columns
data %>%
unite(col = "services_vs_overall", data_services_score:overall_score, sep = "/")
## # A tibble: 4,340 × 10
## iso3c country region income year population services_vs_overall
## <chr> <chr> <chr> <chr> <dbl> <dbl> <chr>
## 1 DNK Denmark Europe & Centr… High … 2023 5946952 98.4666666666666/1…
## 2 FIN Finland Europe & Centr… High … 2023 5584264 96.4333333333333/1…
## 3 POL Poland Europe & Centr… High … 2023 36685849 97.3/100/94.65375
## 4 SWE Sweden Europe & Centr… High … 2023 10536632 96/100/94.41
## 5 ESP Spain Europe & Centr… High … 2023 48373336 91.2/100/94.325
## 6 NLD Netherlands Europe & Centr… High … 2023 17879488 96.9/100/94.3225
## 7 SVN Slovenia Europe & Centr… High … 2023 2120937 97.5333333333333/1…
## 8 PRT Portugal Europe & Centr… High … 2023 10525347 96.8666666666667/1…
## 9 ITA Italy Europe & Centr… High … 2023 58761146 93/100/93.63875
## 10 NOR Norway Europe & Centr… High … 2023 5519594 97.2333333333333/1…
## # ℹ 4,330 more rows
## # ℹ 3 more variables: data_products_score <dbl>, data_sources_score <dbl>,
## # data_infrastructure_score <dbl>
data_small <- data_small %>%
mutate(overall_score = round(overall_score, 2))
data_united <- data_small %>%
unite(col = "overall_score_in_year", overall_score, year, sep = "/")
# Display tibble
data_united
## # A tibble: 24 × 2
## country overall_score_in_year
## <chr> <chr>
## 1 Denmark 95.26/2023
## 2 Finland 95.12/2023
## 3 Poland 94.65/2023
## 4 Poland 94.19/2022
## 5 Finland 93.75/2022
## 6 Denmark 93.2/2022
## 7 Poland 94.59/2021
## 8 Denmark 94.41/2021
## 9 Finland 94.31/2021
## 10 Finland 90.79/2020
## # ℹ 14 more rows
Separate a column
data_separated <- data_united %>%
separate( col = overall_score_in_year, into = c("overall_score", "year"), sep = "/", convert = TRUE)
# Display tibble
data_separated
## # A tibble: 24 × 3
## country overall_score year
## <chr> <dbl> <int>
## 1 Denmark 95.3 2023
## 2 Finland 95.1 2023
## 3 Poland 94.6 2023
## 4 Poland 94.2 2022
## 5 Finland 93.8 2022
## 6 Denmark 93.2 2022
## 7 Poland 94.6 2021
## 8 Denmark 94.4 2021
## 9 Finland 94.3 2021
## 10 Finland 90.8 2020
## # ℹ 14 more rows
Missing Values