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
2024
Central government 1,80 1,80
General government sector, total 14,83 14,28
Municipalities 7,18 6,82
Selfgovernment 8,27 8,13
2023
Central government 1,52 1,52
General government sector, total 14,14 14,03
Municipalities 6,72 7,20
Selfgovernment 8,16 7,61
2022
Central government 1,35 1,35
General government sector, total 13,60 13,00
Municipalities 6,57 6,28
Selfgovernment 7,92 7,67
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 2,7 0,5
* 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)
2008 Jan 2008 Jul 2009 Jan 2009 Jul 2010 Jan
All goods and services 100 103,0 103,5 103,9 105,0
Food etc. 100 105,3 106,0 108,9 111,0
Bread and cereals 100 107,5 109,5 111,5 109,8
Meat 100 106,9 106,5 109,4 110,9
Fish 100 101,8 101,3 104,8 109,7
Milk, cream, cheese and eggs 100 104,9 104,5 103,8 106,6
Butter, margarine, oils and fats 100 104,7 115,7 117,6 122,2
Fruit 100 105,6 103,2 106,6 105,1
Vegetables 100 109,6 110,0 107,3 111,9
Sugar, jam, honey, chocolate and confectionery 100 107,9 108,8 110,1 113,0
Foodproducts n.e.c. 100 108,9 107,7 109,3 110,0
Coffee, tee and cocoa 100 101,5 106,4 106,1 107,2
Mineral waters, soft drinks, fruit and vegetable juices 100 104,1 107,3 114,0 114,4
Alcohol and tobacco 100 104,2 104,2 105,0 105,6
Alcohol 100 104,9 104,9 106,0 107,0
Tobacco 100 103,4 103,4 104,0 104,0
Clothing and footwear 100 102,6 103,1 100,2 101,8
Housing 100 103,9 104,9 105,1 105,9
Furnishing and household services 100 102,6 102,1 114,3 111,5
Medicine, pharmaceutical articles 100 102,0 102,0 104,4 106,2
Transportation 100 102,7 103,7 103,8 104,9
Telephone and postage 100 94,8 94,8 95,0 95,0
Leisure and culture 100 102,0 101,5 99,0 99,3
Restaurants and hotels 100 99,2 100,5 100,6 101,1
Other goods and services 100 100,8 105,0 96,2 98,4
# Import
PRXPRISH_raw <-
  statgl_url("PRXPRISH", lang = language) %>%
  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(" "))[1]
fig_sub   <- unlist(statgl_meta(statgl_url("PRXPRISH", lang = language))$variable)[[226]]

# 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")
1971 January 1971 July 1972 January 1972 July 1973 January
Rate of change from the same period the previous year NA NA 5,7 6,3 7,7
* Consumer

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%