Back


Goal 17: Partnerships for the goals

Public finances


GS Public finances
# Import 
indtagter_raw <-
  statgl_url("OFXREAI", lang = language) %>% 
  statgl_fetch(
    "sector"      = px_all(),
    "transaction" = 43,
    "time"        = px_all(),
    .col_code     = TRUE) %>% 
  as_tibble()

udgifter_raw <-
  statgl_url("OFXREAU", lang = language) %>% 
  statgl_fetch(
    "sector"      = px_all(),
    "transaction" = 44,
    "time"        = px_all(),
    .col_code     = TRUE) %>% 
  as_tibble()

indtagter <- 
  indtagter_raw %>% 
  mutate(transaction = transaction %>% str_remove_all("[:digit:]|[:punct:]|\\+") %>% trimws()) %>% 
  spread(2, 4)

udgifter <- 
  udgifter_raw %>% 
  mutate(transaction = transaction %>% str_remove_all("[:digit:]|[:punct:]|\\+") %>% trimws()) %>% 
  spread(2, 4)

drift <-
  indtagter %>% 
  left_join(udgifter) %>% 
  gather(transaction, value, -(1:2)) %>% 
  mutate(value = value / 10^6,
         time = time %>% make_date())
  
# Plot
drift %>%
  ggplot(aes(
    x     = time,
    y     = value,
    color = transaction
  )) +
  geom_line(size = 2) +
  facet_wrap(~ sector, scales = "free") +
  theme_statgl() + 
  scale_color_statgl() +
  labs(
    title = sdg17$figs$fig1$title[language],
    subtitle = " ",
    x = " ",
    y = sdg17$figs$fig1$y_lab[language],
    color = " ",
    caption = sdg17$figs$fig1$cap[language]
  )

Statbank, revenue

Statbank, expenditure

Method


# Transform
drift <-
  indtagter %>% 
  left_join(udgifter) %>% 
  gather(transaction, value, -(1:2)) %>% 
  mutate(value = value / 10^6,
         value = round(value, 2)) %>% 
  filter(time >= year(Sys.time()) - 5) %>% 
  spread(3, 4) %>% 
  arrange(desc(time))

# Table
drift %>% 
  select(-2) %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  pack_rows(index = table(drift[[2]]) %>% rev()) %>% 
  add_footnote(sdg17$figs$fig1$foot[language], notation = "symbol")
Current surpluss gross saving TOTAL OUTLAYS
2023
Central government 1,52 1,52
General government sector, total 14,13 13,84
Municipalities 6,71 7,18
Selfgovernment 8,15 7,45
2022
Central government 1,32 1,32
General government sector, total 13,57 12,87
Municipalities 6,53 6,21
Selfgovernment 7,92 7,60
2021
Central government 1,39 1,39
General government sector, total 12,78 12,67
Municipalities 6,20 6,13
Selfgovernment 7,33 7,31
2020
Central government 1,36 1,36
General government sector, total 12,87 12,61
Municipalities 6,13 6,04
Selfgovernment 7,61 7,44
* Billions (DKK)



# Import 
indtagter_raw <-
  statgl_url("OFXREAI", lang = language) %>% 
  statgl_fetch(
    "sector"      = 0,
    "transaction" = 43,
    "time"        = px_all(),
    .col_code     = TRUE) %>% 
  as_tibble()

udgifter_raw <-
  statgl_url("OFXREAU", lang = language) %>% 
  statgl_fetch(
    "sector"      = 0,
    "transaction" = 44,
    "time"        = px_all(),
    .col_code     = TRUE) %>% 
  as_tibble()

bnp_raw <-
  statgl_url("NRX02", lang = language) %>% 
  statgl_fetch(
    "units"        = "L",
    "account name" = "LBNPTOT",
    "time"         = px_all(),
    .col_code      = TRUE) %>% 
  as_tibble()

# Transform
saldo <- 
  bnp_raw %>% 
  select(3, 4) %>% 
  rename("bnp" = 2) %>% 
  left_join(udgifter_raw  %>% select(3, 4) %>% rename("expenditure" = 2)) %>% 
  left_join(indtagter_raw %>% select(3, 4) %>% rename("revenue" = 2)) %>% 
  mutate(saldo = (revenue - expenditure) / bnp * 10^-3,
         time  = time %>% make_date(),
         type  = "saldo")

# Plot
saldo %>% 
  ggplot(aes(
    x    = time,
    y    = saldo,
    fill = type
  )) +
  geom_col() +
  scale_y_continuous(labels  = scales::percent_format(
    scale = 100, 
    accuracy = 1,
    big.mark = ".",
    decimal.mark = ","
    )) +
  theme_statgl() + 
  scale_fill_statgl() +
  theme(legend.position = "None") +
  labs(
    title = sdg17$figs$fig2$title[language],
    subtitle = sdg17$figs$fig2$sub[language],
    x = " ",
    y = sdg17$figs$fig2$y_lab[language],
    color = " ",
    caption = sdg17$figs$fig2$cap[language]
  )

Statbank, revenue

Statbank, expenditure

Statbank, GDP

Method, public finances


# transform
  saldo <-
  bnp_raw %>% 
  select(3, 4) %>% 
  rename("bnp" = 2) %>% 
  left_join(udgifter_raw  %>% select(3, 4) %>% rename("expenditure" = 2)) %>% 
  left_join(indtagter_raw %>% select(3, 4) %>% rename("revenue" = 2)) %>% 
  filter(time >= year(Sys.time()) - 7) %>% 
  #arrange(desc(time)) %>% 
  mutate(value = (revenue - expenditure) / bnp * 10^-3 * 100,
         value = round(value, 1),
         time  = time %>% factor(levels = unique(time)),
         saldo = sdg17$figs$fig2$saldo[language]) %>% 
  select(-(2:4)) %>% 
  spread(1, 2)



# table
saldo %>%
  rename(" " = 1) %>% 
  statgl_table() %>% 
  add_footnote(sdg17$figs$fig2$foot[language], notation = "symbol")
2018 2019 2020 2021 2022 2023
Actual government balance 6 6,2 1,3 0,5 3,1 1,2
* Share of GDP

Consumer prices


GS Consumer price index
# Import
PRXPRISV_raw <-
  statgl_url("PRXPRISV", lang = language) %>% 
  statgl_fetch(
      "commodity group" = px_all(),
      "time"            = px_all(),
    .col_code           = TRUE) %>% 
  as_tibble()

# Transform
PRXPRISV <- 
  PRXPRISV_raw %>% 
  mutate(time              = time %>% as.character() %>% readr::parse_date(format = "%Y %b"),
         `commodity group` = `commodity group` %>% factor(levels = unique(`commodity group`)))

# Plot  
cpi <-
  PRXPRISV %>% 
  ggplot(aes(
    x     = time,
    y     = value,
    color = `commodity group` 
  )) +
  geom_line(linewidth = 1) +
  theme_statgl() + 
  scale_color_statgl() +
  labs(
    title    = (statgl_url("PRXPRISV", lang = language) %>% statgl_meta())$title,
    subtitle = " ",
    x        = " ",
    y        = sdg17$figs$fig3$y_lab[language],
    color    = sdg17$figs$fig3$color[language],
    caption  = sdg17$figs$fig3$cap[language]
  )
  
plotly::ggplotly(cpi)
StatBank

Method


# Import
PRXPRISV_raw <-
  statgl_url("PRXPRISV", lang = language) %>% 
  statgl_fetch(
      "commodity group" = px_all(),
      "time"            = px_top(5),
    .col_code           = TRUE) %>% 
  as_tibble()

# Transform
PRXPRISV <-
  PRXPRISV_raw %>% 
  #arrange(desc(time)) %>% 
  mutate(time = time %>% factor(levels = unique(time)),
         `commodity group` = `commodity group` %>% factor(levels = unique(`commodity group`))) %>% 
  spread(2, 3)

# Table
PRXPRISV %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  row_spec(1, bold = TRUE)
2023 Jan 2023 Jul 2024 Jan 2024 Jul 2025 Jan
All goods and services 127,0 129,0 129,8 132,7 134,4
Food etc. 147,5 150,1 151,1 154,1 156,5
Bread and cereals 139,5 146,4 146,1 149,2 153,9
Meat 149,6 150,9 152,1 152,1 153,9
Fish 126,6 127,3 127,2 127,2 127,4
Milk, cream, cheese and eggs 140,4 142,2 142,0 143,3 151,9
Butter, margarine, oils and fats 205,6 205,7 211,8 215,4 231,1
Fruit 135,9 135,9 145,8 145,2 147,8
Vegetables 151,6 153,0 150,5 154,5 160,6
Sugar, jam, honey, chocolate and confectionery 176,3 178,6 180,5 182,0 181,9
Foodproducts n.e.c. 139,7 144,5 143,4 157,0 159,8
Coffee, tee and cocoa 143,5 145,0 145,6 150,9 153,1
Mineral waters, soft drinks, fruit and vegetable juices 161,2 165,7 168,1 177,4 178,3
Alcohol and tobacco 133,0 134,2 135,5 138,5 141,0
Alcohol 130,6 132,1 133,5 139,0 139,8
Tobacco 134,9 135,9 137,0 137,9 141,7
Clothing and footwear 90,6 91,3 92,2 95,4 98,8
Housing 127,7 129,4 130,1 134,8 138,2
Furnishing and household services 122,7 123,1 117,8 116,3 114,2
Medicine, pharmaceutical articles 131,5 132,8 132,5 130,3 132,3
Transportation 128,5 129,1 132,6 134,3 133,4
Telephone and postage 85,5 85,5 85,6 85,6 85,6
Leisure and culture 114,2 120,3 119,6 125,0 122,6
Restaurants and hotels 137,9 141,1 142,4 143,8 145,1
Other goods and services 119,5 121,3 123,3 123,3 126,9
# Import
PRXPRISH_raw <-
  statgl_url("PRXPRISH", lang = "da") %>%
  statgl_fetch(
      "time"  = px_all(),
      "type"  = 0,
    .col_code = TRUE) %>% 
  as_tibble()



time <- statgl_url("PRXPRISH", lang = "en") %>%
  statgl_fetch(
      "time"  = px_all()) %>% 
  select(time_eng = time)

fig_title <- unlist(statgl_meta(statgl_url("PRXPRISH", lang = language))$title %>% str_split(", "))[2]
fig_sub   <- unlist(statgl_meta(statgl_url("PRXPRISH", lang = language))$title %>% str_split(", "))[1]

# Transform
PRXPRISH <-
  PRXPRISH_raw %>% 
  cbind(time) %>% 
  mutate(time = time_eng %>% parse_date(format = "%Y %B")) %>% 
  select(-time_eng)


fig_title <- unlist(statgl_meta(statgl_url("PRXPRISH", lang = language))$title %>% str_split(", "))[2]
fig_sub   <- unlist(statgl_meta(statgl_url("PRXPRISH", lang = language))$title %>% str_split(", "))[1]

# Plot
PRXPRISH %>% 
  ggplot(aes(
    x     = time,
    y     = value,
    color = type
  )) +
  geom_line(size = 2) +
  scale_y_continuous(labels  = scales::percent_format(
    scale = 1, 
    accuracy = 1, 
    big.mark = ".",
    decimal.mark = ","
    )) +
  theme_statgl() + 
  scale_color_statgl() +
  theme(legend.position = "none") +
  labs(
    title    = fig_title,
    subtitle = fig_sub,
    x        = " ",
    y        = " ",
    caption  = sdg17$figs$fig4$cap[language]
  ) 

StatBank

Method


# Import
PRXPRISH_raw <-
  statgl_url("PRXPRISH", lang = language) %>%
  statgl_fetch(
      "time"  = px_top(5),
      "type"  = 0,
    .col_code = TRUE) %>% 
  as_tibble()

# Transform
PRXPRISH <-
  PRXPRISH_raw %>% 
  #arrange(desc(time)) %>% 
  mutate(time = time %>% factor(levels = unique(time))) %>% 
  spread(1, ncol(.))

PRXPRISH %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  add_footnote(fig_title, notation = "symbol")
2023 January 2023 July 2024 January 2024 July 2025 January
Rate of change from the same period the previous year 2,7 2,5 2,2 2,8 3,6
* Consumer price index

Supply balance


GS Supply balance
# Import
NRX11_raw <-
  statgl_url("NRX11", lang = language) %>% 
  statgl_fetch(
      "units"   = "K",
      "account" = px_all(),
      "time"    = px_all(),
    .col_code   = TRUE) %>% 
  as_tibble()

var <- unique(NRX11_raw[[2]])
vec <- c(var[1], var[4], var[5], var[6], var[7], var[2])

# Transform
NRX11 <-
  NRX11_raw %>% 
  filter(account %in% vec) %>% 
  mutate(account = account %>% factor(levels = unique(vec)),
         time    = time    %>% make_date()) %>% 
  arrange(account, time) %>% 
  group_by(account) %>% 
  mutate(pct = (value - lag(value)) / lag(value)) %>% 
  ungroup()

# Plot
NRX11 %>% 
  ggplot(aes(
    x     = time,
    y     = pct,
    color = account
  )) +
  geom_line(size = 2) +
  geom_hline(yintercept = 0, linetype = "dashed") + 
  facet_wrap(~ account, scales = "free") +
  scale_y_continuous(labels  = scales::percent_format(
    scale        = 100, 
    accuracy     = 1, 
    big.mark     = ".",
    decimal.mark = ","
  )) +
  theme_statgl() + 
  scale_color_statgl() +
  labs(
    title    = sdg17$figs$fig5$title[language],
    subtitle = NRX11[[1]][1],
    x        = " ",
    y        = sdg17$figs$fig5$y_lab[language],
    color    = " ",
    caption  = sdg17$figs$fig5$cap[language]
  )

StatBank


# Transform
NRX11 <-
  NRX11_raw %>% 
  filter(account %in% vec) %>% 
  mutate(account = account %>% factor(levels = unique(vec))) %>% 
  arrange(account, time) %>% 
  group_by(account) %>% 
  mutate(pct = (value - lag(value)) / lag(value) * 100,
         pct = round(pct, 1)) %>% 
  ungroup() %>% 
  #arrange(desc(time)) %>% 
  filter(time >= year(Sys.time()) - 5) %>% 
  mutate(time = time %>% factor(levels = unique(time))) %>% 
  select(-4) %>% 
  spread(3, 4)

# Table
NRX11 %>% 
  select(-1) %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  pack_rows(sdg17$figs$fig5$index[language], 1, length(NRX11[[2]])) %>% 
  add_footnote(NRX11[[1]][1], notation = "symbol")
2020 2021 2022 2023
Annual percentage change
Gross Domestic Product 0,3 1,6 2,0 0,9
Private consumption -0,3 3,2 0,6 0,1
Government consumption -2,9 2,3 -1,7 2,2
Gross investment 7,0 13,7 1,8 -3,6
Exports of goods and services -4,0 -6,0 13,9 3,0
Imports of goods and services -2,1 6,0 5,7 -0,1
* 2010-prices, chained values

Government consumption and block grants


GS Government consumption and block grants
# Import 
NRD11_raw <- 
  statgl_url("NRX11", lang = language) %>% 
  statgl_fetch(
    units   = "L",
    account = c("0000", "3200"),
    time    = px_all(),
    .col_code   = TRUE
  ) %>% 
  as_tibble()

OFXREAI_raw <- 
  statgl_url("OFXREAI", lang = language) %>% 
  statgl_fetch(
    sector      = c(0),
    transaction = c(27),
    time        = px_all(),
    .col_code   = TRUE
  ) %>% 
  as_tibble()

# Transform
bnp <- 
  NRD11_raw %>% 
  mutate(account = account %>% factor(levels = unique(account))) %>% 
  spread(account, value) %>% 
  left_join(OFXREAI_raw %>%
              mutate(
                transaction = transaction %>% 
                  trimws() %>% 
                  str_remove_all("[:digit:]") %>% 
                  str_remove("...") %>%
                  trimws(),
                value = value / 1000
                ) %>% 
              spread(transaction, value) %>% 
              select(-1)
            )
  
labels     <- bnp %>% colnames()
vec        <- 1:length(labels)
names(vec) <- labels

bnp_relativ <-
  bnp %>% 
  rename(
    Y = 3,
    O = 4,
    B = 5
  ) %>% 
  mutate(
    O = O / Y * 100,
    B = B / Y * 100
  ) %>% rename(vec) %>% 
  select(-3) %>% 
  gather(key, value, -units, -time) %>% 
  mutate(time = time %>% as.numeric(),
         key  = key %>% factor(levels = unique(key)))


sub_lab <- 
  bnp_relativ %>% 
  select(1) %>% 
  separate(units, c("units", "drop"), ",") %>% 
  pull(units) %>% 
  unique()


# Plot
bnp_relativ %>% 
  ggplot(aes(
    x     = time,
    y     = value,
    fill  = key
  )) +
  geom_col(size = 2) +
  facet_wrap(~ key, scales = "free", ncol = 1) +
  theme_statgl() + 
  theme(legend.position = "none") +
  scale_y_continuous(labels  = scales::percent_format(
    scale = 1
  )) +
  scale_fill_statgl() +
  labs(
    title    = sdg17$figs$fig6$title[language],
    subtitle = sub_lab,
    y        = " ",
    x        = " ",
    caption  = sdg17$figs$fig6$cap[language]
  )

StatBank


# Table
tab <- 
  bnp_relativ %>% 
  #arrange(desc(time)) %>% 
  filter(time >= year(Sys.time()) - 7) %>% 
  mutate(
    time = time %>% factor(levels = unique(time)),
    value = value %>% round(1)
    ) %>% 
  spread(time, value)

foot_lab <- 
  tab %>% 
  select(1) %>% 
  separate(units, c("units", "drop"), ",") %>% 
  pull(units) %>%
  table()

tab %>% 
  select(-1) %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  pack_rows(index = foot_lab) %>% 
  add_footnote(sdg17$figs$fig6$foot[language], notation = "symbol")
2018 2019 2020 2021 2022 2023
Current prices
Government consumption 43,1 43,8 43,6 44,3 41,3 41,7
Block grants 19,9 19,3 19,4 19,0 17,9 18,1
* Share of GDP

High-speed internet


GS High-speed internet
# Import 
time  <- seq(2018, 2020)
value <- c(80, 92.6, 92.6) 
type  <- "internet"

title   <- sdg17$figs$fig7$title[language]
caption <- sdg17$figs$fig7$cap[language]
unit    <- sdg17$figs$fig7$unit[language]


# Plot
data.frame(time, value, type) %>% 
  as_tibble() %>% 
  ggplot(aes(
    x = time, 
    y = value,
    fill = type
    )) + 
  geom_col() +
  expand_limits(y = 100) +
  scale_y_continuous(labels  = scales::percent_format(
    scale        = 1,
    accuracy     = 1,
    big.mark     = ".",
    decimal.mark = ","
  )) +
  scale_fill_statgl() +
  theme_statgl() + 
  theme(legend.position = "none") +
  labs(
    title    = title,
    subtitle = unit,
    x        = " ",
    y        = " ",
    caption  = caption
  )




# Table 
value <- c("80%", "92.6%", "92.6%") 

data.frame(time, value) %>% 
  as_tibble() %>% 
  mutate(col = title) %>% 
  spread(time, value) %>% 
  rename(" " = 1) %>% 
  statgl_table()
2018 2019 2020
Access to high-speed internet 80% 92.6% 92.6%