Tilbage


Delmål 3: Sundhed og trivsel

Aborter


GS Aldersstandardiseret rate hos kvinder i alderen 12-49 år
# Helper function:
age_adjust <- function(count, pop, rate = NULL, stdpop){
  if (missing(count) & !missing(pop) & is.null(rate)) {
    count <- rate * pop
  }
  
  if (missing(pop) & !missing(count) & is.null(rate)) {
    pop <- count/rate
    pop[!is.finite(pop)] <- 0
  }
  
  if (is.null(rate) & !missing(count) & !missing(pop)){
    rate <- count/pop
    rate[!is.finite(rate)] <- 0
  }

  cruderate <- sum(count)/sum(pop)
  stdwt <- stdpop/sum(stdpop)
  dsr <- sum(stdwt * rate)
  
  tibble(`crude_rate` = cruderate, `std_rate` = dsr)
}

# Import
SUDA2_raw <- 
  statgl_url("SUXA2", lang = "da") %>% 
  statgl_fetch(.eliminate_rest = FALSE) %>% 
  as_tibble() %>% 
    rename(Aborter = value)

# Tidy
SUDA_2 <- 
  SUDA2_raw %>% 
  as_tibble() %>% 
  spread(enhed, Aborter) %>% 
  mutate_at(c(1, 2), strtoi)

# Standardize
SUDA_2_2000 <- SUDA_2 %>% filter(tid == 2000) %>% pull(Middelfolketal)

SUDA2_std <- 
  SUDA_2 %>% 
  group_by(tid) %>% 
  summarise(age_adjust(Aborter, Middelfolketal, stdpop = SUDA_2_2000) * 1000)

# Plot
SUDA2_std %>% 
  ggplot(aes(x = tid, y = std_rate)) +
  geom_line(size = 2, color = statgl:::statgl_cols("darkblue"))+
  theme_statgl() +
  theme(plot.margin = margin(10, 10, 10, 10)) +
  labs(
    title    = sdg3$figs$fig1$title[language], 
    x        = " ", 
    y        = sdg3$figs$fig1$y_lab[language], 
    subtitle = sdg3$figs$fig1$sub[language]
    )

Statistikbanken


# Helper function:
age_adjust <- function(count, pop, rate = NULL, stdpop){
  if (missing(count) & !missing(pop) & is.null(rate)) {
    count <- rate * pop
  }
  
  if (missing(pop) & !missing(count) & is.null(rate)) {
    pop <- count/rate
    pop[!is.finite(pop)] <- 0
  }
  
  if (is.null(rate) & !missing(count) & !missing(pop)){
    rate <- count/pop
    rate[!is.finite(rate)] <- 0
  }

  
  cruderate <- sum(count)/sum(pop)
  stdwt <- stdpop/sum(stdpop)
  dsr <- sum(stdwt * rate)
  
  tibble(`crude_rate` = cruderate, `std_rate` = dsr)
}

# Import
SUDA2_raw <- 
  statgl_url("SUXA2", lang = "da") %>% 
  statgl_fetch(.eliminate_rest = FALSE) %>% 
  as_tibble() %>% 
  rename(Aborter = value)

# Tidy
SUDA_2 <- 
  SUDA2_raw %>% 
  as_tibble() %>% 
  spread(enhed, Aborter) %>% 
  mutate_at(c(1, 2), strtoi)

# Standardize
SUDA_2_2000 <- SUDA_2 %>% filter(tid == 2000) %>% pull(Middelfolketal)

SUDA2_std <- 
  SUDA_2 %>% 
  group_by(tid) %>% 
  summarise(age_adjust(Aborter, Middelfolketal, stdpop = SUDA_2_2000) * 1000,
            Aborter = sum(Aborter), Middelfolketal = sum(Middelfolketal))


vec        <- 2:5
names(vec) <- c(
    sdg3$figs$fig1$cols$col2[language],
    sdg3$figs$fig1$cols$col3[language],
    sdg3$figs$fig1$cols$col4[language],
    sdg3$figs$fig1$cols$col5[language]
    )

# Table
SUDA2_std %>% 
  arrange(desc(tid)) %>% 
  filter(tid > year(Sys.time()) - 7) %>% 
  rename(vec) %>% 
  gather(key, value, -tid) %>% 
  mutate(
    key   = key %>% fct_inorder(),
    value = value %>% round(1),
    tid   = tid %>% factor(levels = unique(tid))
    ) %>% 
  spread(1, 3) %>% 
  rename(" " = 1) %>% 
  statgl_table()
2019 2018 2017 2016
Aborter pr. 1000 64,7 66,4 62,3 59,5
Aldersstandardiseret rate pr. 1000 kvinder, 12-49 år 56,2 57,9 54,5 52,4
Aborter 902,0 931,0 883,0 855,0
Middelfolketal 13.941,0 14.019,0 14.169,0 14.364,0
Senest opdateret: 07. april 2022

Middellevetid


GS Middellevetid for 0 og 1 - årige personer født i Grønland
# Import
BEXDT5A_raw <-
  statgl_url("BEXDT5A", lang = language) %>% 
  statgl_fetch(
    type      = "E",
    age       = c(0, 1),
    .col_code = TRUE) %>% 
  as_tibble()

# Transform
BEXDT5A <- 
  BEXDT5A_raw %>% 
  separate(time, into = c("startaar", "slutaar"), sep = " - ") %>% 
  mutate(slutaar = slutaar %>% as.numeric %>% make_date()) %>% 
  select(-3)

# Plot
BEXDT5A %>% 
  ggplot(aes(
    x     = slutaar, 
    y     = value, 
    color = age
    )) +
  geom_line(size = 2) +
  scale_y_continuous(labels = scales::unit_format(
    suffix       = " ",
    big.mark     = ".",
    decimal.mark = ","
    )) +
  theme_statgl() + 
  scale_color_statgl() +
  labs(
    title    = sdg3$figs$fig2$title[language],
    subtitle = sdg3$figs$fig2$sub[language],
    x        = sdg3$figs$fig2$x_lab[language],
    y        = BEXDT5A[[1]][1],
    color    = sdg3$figs$fig2$color[language],
    caption  = sdg3$figs$fig2$cap[language]
  )

Statistikbanken

Metode


# Transform
BEXDT5A <-
  BEXDT5A_raw %>% 
  mutate(timetime = time) %>% 
  separate(timetime, c("tip", "top"), sep = " - ") %>% 
  arrange(desc(top)) %>% 
  filter(top >= year(Sys.time()) - 5) %>% 
  mutate(time = time %>% factor(levels = unique(time))) %>% 
  select(-(5:6)) %>% 
  spread(3, 4)

# Table  
BEXDT5A %>% 
  select(-1) %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  pack_rows(index = table(BEXDT5A[[1]]))
2015 - 2019 2014 - 2018 2013 - 2017
Middellevetid
0 70,46 70,70 70,63
1 70,09 70,27 70,22
# Import
BEXDT5A_raw <-
  statgl_url("BEXDT5A", lang = language) %>%
  statgl_fetch(
    type = "E",
    age = c(0, 1),
    residence = 1:2,
    .col_code = TRUE) %>% 
  as_tibble()

# Transform
BEXDT5A <- 
  BEXDT5A_raw %>% 
  separate(time, into = c("startaar", "slutaar"), sep = " - ") %>% 
  mutate(slutaar = as.numeric(slutaar) %>% make_date()) %>% 
  select(-4)

# Plot
BEXDT5A %>% 
  ggplot(aes(
    x      = slutaar,
    y      = value,
    color  = age
  )) +
  geom_line(size = 2) +
  facet_wrap(~ residence) +
  scale_y_continuous(labels = scales::unit_format(
    suffix       = " ",
    big.mark     = ".",
    decimal.mark = ","
  )) +
  theme_statgl() +
  theme(plot.margin = margin(10, 10, 10, 10)) +
  scale_color_statgl(
    reverse = TRUE, 
    guide = guide_legend(reverse = TRUE)
    ) +
  labs(
    title    = sdg3$figs$fig3$title[language],
    subtitle = sdg3$figs$fig3$sub[language],
    x        = sdg3$figs$fig3$x_lab[language],
    y        = BEXDT5A[[1]][1],
    color    = sdg3$figs$fig3$color[language],
    caption  = sdg3$figs$fig3$cap[language]
  )

Statistikbanken

Metode


# Transform
BEXDT5A <-
  BEXDT5A_raw %>% 
  mutate(timetime = time) %>% 
  separate(timetime, c("tip", "top"), sep = " - ") %>% 
  arrange(desc(top), age) %>% 
  filter(top >= year(Sys.time()) - 5) %>% 
  unite(combi, 3, 2, sep = ",") %>% 
  mutate(
    combi = combi %>% factor(levels = unique(combi)),
    time  = time  %>% factor(levels = unique(time))
    ) %>% 
  select(-(5:6)) %>% 
  spread(2, 4)

vec      <- BEXDT5A %>% select(-(1:2)) %>% colnames() %>% str_split(",") %>% unlist()
head_vec <- vec[c(T, F)] %>% table()
col_vec  <- vec[c(F, T)]

# Table
BEXDT5A %>% 
  select(-1) %>%
  rename(" " = 1) %>% 
  statgl_table(col.names = c(" ", col_vec)) %>% 
  add_header_above(c(" ", head_vec)) %>% 
  pack_rows(index = table(BEXDT5A[[1]]))
0
1
By Bygd By Bygd
Middellevetid
2015 - 2019 70,73 68,74 70,41 68,08
2014 - 2018 70,89 69,56 70,54 68,68
2013 - 2017 70,81 69,60 70,49 68,72

Dødelighed


GS Aldersstandardiseret dødelighedsrate
# Helper function:
age_adjust <- function(count, pop, rate = NULL, stdpop){
  if (missing(count) & !missing(pop) & is.null(rate)) {
    count <- rate * pop
  }
  
  if (missing(pop) & !missing(count) & is.null(rate)) {
    pop <- count/rate
    pop[!is.finite(pop)] <- 0
  }
  
  if (is.null(rate) & !missing(count) & !missing(pop)){
    rate <- count/pop
    rate[!is.finite(rate)] <- 0
  }

 
  cruderate <- sum(count)/sum(pop)
  stdwt <- stdpop/sum(stdpop)
  dsr <- sum(stdwt * rate)
  
  tibble(`crude_rate` = cruderate, `std_rate` = dsr)
}

# Import
BEDBBDM1_raw <-
  statgl_url("BEXBBDM1", lang = "da") %>% 
  statgl_fetch(
    type      = px_all(),
    age       = px_all(),
    .col_code = TRUE) %>% 
  as_tibble() %>% 
    rename(c(
      "alder"    = 1,
      "art"      = 2,
      "tid"      = 3,
      "Dødsfald" = 4
      ))

BEDBBM1 <- BEDBBDM1_raw %>% as_tibble() %>% spread(art, Dødsfald) %>% 
  mutate_at(1:2, strtoi) 

BEDBBM1_2000 <- BEDBBM1 %>% filter(tid == 2000) %>% pull(Middelfolketal)

BEDBBM1_std <- BEDBBM1 %>% 
  group_by(tid) %>% 
  summarise(age_adjust(Døde, Middelfolketal, stdpop = BEDBBM1_2000) * 1000) %>% 
  ungroup()

BEDBBM1_std %>% 
  ggplot(aes(
    x = tid, 
    y = std_rate
    )) +
  geom_line(size = 2, color = statgl:::statgl_cols("darkblue")) +
  theme_statgl() +
  labs(
    title    = sdg3$figs$fig4$title[language],
    subtitle = sdg3$figs$fig4$sub[language],
    y        = sdg3$figs$fig4$y_lab[language]
  )

Statistikbanken

Metode


# Helper function:
age_adjust <- function(count, pop, rate = NULL, stdpop){
  if (missing(count) & !missing(pop) & is.null(rate)) {
    count <- rate * pop
  }
  
  if (missing(pop) & !missing(count) & is.null(rate)) {
    pop <- count/rate
    pop[!is.finite(pop)] <- 0
  }
  
  if (is.null(rate) & !missing(count) & !missing(pop)){
    rate <- count/pop
    rate[!is.finite(rate)] <- 0
  }

  cruderate <- sum(count)/sum(pop)
  stdwt <- stdpop/sum(stdpop)
  dsr <- sum(stdwt * rate)
  
  tibble(`crude_rate` = cruderate, `std_rate` = dsr)
}

# Import
BEDBBDM1_raw <-
  statgl_url("BEXBBDM1", lang = "da") %>% 
  statgl_fetch(
    type      = px_all(),
    age       = px_all(),
    .col_code = TRUE) %>% 
  as_tibble() %>% 
    rename(c(
      "alder"    = 1,
      "art"      = 2,
      "tid"      = 3,
      "Dødsfald" = 4
      ))

BEDBBM1 <- BEDBBDM1_raw %>% as_tibble() %>% spread(art, Dødsfald) %>% 
  mutate_at(1:2, strtoi) 

BEDBBM1_2000 <- BEDBBM1 %>% filter(tid == 2000) %>% pull(Middelfolketal)

BEDBBM1_std <- BEDBBM1 %>% 
  group_by(tid) %>% 
  summarise(age_adjust(Døde, Middelfolketal, stdpop = BEDBBM1_2000) * 1000) %>% 
  ungroup()

vec <- 2:3
names(vec) <- c(
  sdg3$figs$fig4$cols$col2[language], 
  sdg3$figs$fig4$cols$col3[language]
  )

BEDBBM1_std %>% 
  arrange(desc(tid)) %>% 
  filter(tid > year(Sys.time()) - 7) %>% 
  rename(vec) %>% 
  gather(key, value, -tid) %>% 
  mutate(
    tid   = tid %>% factor(levels = unique(tid)), 
    value = value %>% round(3)
    ) %>% 
  spread(1, 3) %>% 
  rename(" " = 1) %>% 
  statgl_table()
2021 2020 2019 2018 2017 2016
Crude Rate 9,404 9,267 9,784 8,712 8,937 8,724
Std. Rate 5,787 5,699 6,073 5,428 5,857 5,726
# Helper function:
age_adjust <- function(count, pop, rate = NULL, stdpop){
  if (missing(count) & !missing(pop) & is.null(rate)) {
    count <- rate * pop
  }
  
  if (missing(pop) & !missing(count) & is.null(rate)) {
    pop <- count/rate
    pop[!is.finite(pop)] <- 0
  }
  
  if (is.null(rate) & !missing(count) & !missing(pop)){
    rate <- count/pop
    rate[!is.finite(rate)] <- 0
  }

  
  cruderate <- sum(count)/sum(pop)
  stdwt <- stdpop/sum(stdpop)
  dsr <- sum(stdwt * rate)
  
  tibble(`crude_rate` = cruderate, `std_rate` = dsr)
}

# Import
BEDBBDM1_raw <-
  statgl_url("BEXBBDM1", lang = "da") %>%
  statgl_fetch(
    type      = px_all(),
    age       = px_all(),
    gender    = c("M", "K"),
    .col_code = TRUE) %>% 
  as_tibble() %>% 
    rename(c(
      "alder"    = 1,
      "art"      = 2,
      "køn"      = 3,
      "tid"      = 4,
      "Dødsfald" = 5
      ))

BEDBBDM1 <- BEDBBDM1_raw %>% as_tibble() %>% spread(art, Dødsfald) %>% 
  mutate_at(c(1, 3), strtoi)

BEDBBDM1_2000 <- BEDBBDM1 %>% arrange(tid, køn, alder) %>% filter(tid == 2000) %>% pull(Middelfolketal)

BEDBBDM1_std <- BEDBBDM1 %>% group_by(tid, køn) %>% arrange(alder) %>% 
  summarise(age_adjust(Døde, Middelfolketal, stdpop = BEDBBDM1_2000) * 1000) %>% 
  ungroup()

BEDBBDM1_std %>% 
  ggplot(aes(
    x     = tid, 
    y     = std_rate, 
    color = køn
  )) +
  geom_line(size = 2) + 
  theme_statgl() +
  scale_color_statgl(reverse = TRUE) +
  labs(
    title    = sdg3$figs$fig5$title[language], 
    subtitle = sdg3$figs$fig5$sub[language],
    color    = " ", 
    x        = " ",
    y        = sdg3$figs$fig5$y_lab[language]
  )

Statistikbanken

Metode


# Helper function:
age_adjust <- function(count, pop, rate = NULL, stdpop){
  if (missing(count) & !missing(pop) & is.null(rate)) {
    count <- rate * pop
  }
  
  if (missing(pop) & !missing(count) & is.null(rate)) {
    pop <- count/rate
    pop[!is.finite(pop)] <- 0
  }
  
  if (is.null(rate) & !missing(count) & !missing(pop)){
    rate <- count/pop
    rate[!is.finite(rate)] <- 0
  }

  cruderate <- sum(count)/sum(pop)
  stdwt <- stdpop/sum(stdpop)
  dsr <- sum(stdwt * rate)
  
  tibble(`crude_rate` = cruderate, `std_rate` = dsr)
}

# Import
BEDBBDM1_raw <-
  statgl_url("BEXBBDM1", lang = "da") %>%
  statgl_fetch(
    type      = px_all(),
    age       = px_all(),
    gender    = c("M", "K"),
    .col_code = TRUE) %>% 
  as_tibble() %>% 
    rename(c(
      "alder"    = 1,
      "art"      = 2,
      "køn"      = 3,
      "tid"      = 4,
      "Dødsfald" = 5
      ))

BEDBBDM1 <- 
  BEDBBDM1_raw %>% 
  spread(art, Dødsfald) %>% 
  mutate_at(c(1, 3), strtoi)

BEDBBDM1_2000 <- BEDBBDM1 %>% arrange(tid, køn, alder) %>% filter(tid == 2000) %>% pull(Middelfolketal)

BEDBBDM1_std <- BEDBBDM1 %>% group_by(tid, køn) %>% arrange(alder) %>% 
  summarise(age_adjust(Døde, Middelfolketal, stdpop = BEDBBDM1_2000) * 1000) %>% 
  ungroup()

vec        <- 2:3
names(vec) <- 
  c(
    sdg3$figs$fig4$cols$col2[language], 
    sdg3$figs$fig4$cols$col3[language]
    )

step <- 
  BEDBBDM1_std %>% 
  arrange(desc(tid)) %>% 
  filter(tid > year(Sys.time()) - 5) %>% 
  unite(combi, 1, 2, sep = ",") %>% 
  rename(vec) %>% 
  gather(key, value, -combi) %>% 
  mutate(
    combi = combi %>% fct_inorder(),
    key   = key %>% fct_inorder(),
    value = value %>% round(3)
  ) %>% 
  spread(1, 3)

vecvec   <- step[-1] %>% colnames() %>% str_split(",") %>% unlist()
head_vec <- vecvec[c(T, F)] %>% table() %>% rev()
col_vec  <- vecvec[c(F, T)]

step %>% 
  rename(" " = 1) %>% 
  statgl_table(
    col.names = c(" ", col_vec)
    ) %>% 
  add_header_above(c(" ", head_vec))



Tuberkulose


FN 3.3.2 Nye tuberkulosetilfælde pr. 100.000 indbyggere
# Import
TUB01_raw <- 
  read_csv(
  "http://pxweb.fujitsu.dk/sq/1417044b-c578-4c3a-a97d-5056b117ad52",
  locale = locale(encoding = "latin1")) %>%
  as_tibble()

# Transform
TUB01 <- 
  TUB01_raw %>% 
  mutate(
    sex  = sex %>% str_replace("Men",   sdg3$figs$fig5$groups$group1[language] %>% unlist()),
    sex  = sex %>% str_replace("Women", sdg3$figs$fig5$groups$group2[language] %>% unlist()),
    year = year %>% make_date()
    )

# Plot
TUB01 %>% 
  ggplot(aes(
    x     = year, 
    y     = Greenland, 
    color = sex
    )) +
  geom_line(size = 2) +
  expand_limits(y = 0) +
  theme_statgl() + 
  scale_color_statgl(reverse = TRUE) +
  labs(
    title    = sdg3$figs$fig6$title[language],
    subtitle = sdg3$figs$fig6$sub[language],
    x        = " ",
    y        = sdg3$figs$fig6$y_lab[language],
    color    = " ",
    caption  = sdg3$figs$fig6$cap[language]
  )

Tabel, NOMESCO


# Transform
TUB01 <- 
  TUB01_raw %>% 
  mutate(
    sex = sex %>% str_replace("Men",   sdg3$figs$fig5$groups$group1[language] %>% unlist()),
    sex = sex %>% str_replace("Women", sdg3$figs$fig5$groups$group2[language] %>% unlist())
    ) %>% 
  arrange(desc(year)) %>% 
  filter(year >= year(Sys.time()) - 7) %>% 
  mutate(year = year %>% factor(levels = unique(year))) %>% 
  spread(2, 3)

# Table
TUB01 %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  pack_rows(index = rep(sdg3$figs$fig6$index[language] %>% unlist(), length(TUB01[[1]])) %>% table()) %>% 
  add_footnote(
    sdg3$figs$fig6$foot[language], 
    notation = "symbol"
    )
2016 2015
Diagnosticerede tilfælde af tuberkulose
Kvinder 64,2 105,9
Mænd 148,1 165,8
* Per hundrede tusinde personer

Selvmord


FN 3.4.3 Selvmordsrate
# Import
SUDLDM2_raw <- 
  read_csv(paste0("https://bank.stat.gl:443/sq/3efbaaab-3db0-4b90-8f7b-18c556afe4e4", "?lang=", language),
    locale = locale(encoding = "latin1"))

BEDSTM1_raw <- 
  read_csv(paste0("https://bank.stat.gl:443/sq/e8c2ed7c-ed03-471b-87e1-40d658b78bd4", "?lang=", language))

# Transform
Selvmord <-
  SUDLDM2_raw %>% 
  left_join(BEDSTM1_raw) %>% 
  rename(
    "cause"      = 1,
    "time"       = 2,
    "suicide"    = 3,
    "population" = 4
    ) %>% 
  mutate(rate = suicide / population * 10^5,
         time = time %>% make_date())

# Plot
Selvmord %>% 
  ggplot(aes(
    x = time,
    y = rate,
    color = statgl:::statgl_cols("darkblue")
  )) +
  geom_line(size = 2) +
  theme_statgl() + scale_color_statgl() +
  theme(legend.position = "none") +
  labs(
    title   = Selvmord[[1]][1],
    x       = " ",
    y       = sdg3$figs$fig7$y_lab[language],
    caption = sdg3$figs$fig7$cap[language]
  )

Statistikbanken


# Transform
Selvmord <-
  SUDLDM2_raw %>% 
  left_join(BEDSTM1_raw) %>% 
  rename(
    "cause"      = 1,
    "time"       = 2,
    "suicide"    = 3,
    "population" = 4
    ) %>% 
  mutate(rate = (suicide / population * 10^5) %>% round(2)) %>% 
  arrange(desc(time)) %>% 
  filter(time >= year(Sys.time()) - 7) %>% 
  select(-(3:4)) %>% 
  mutate(time = time %>% factor(levels = unique(time))) %>% 
  spread(2, 3)

# Table
Selvmord %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  add_footnote(
    sdg3$figs$fig7$foot[language], 
    notation = "symbol"
    )
2020 2019 2018 2017 2016 2015
Selvmord og selvmordsforsøg 0 78,58 80,53 71,61 85,95 57,16
* per hundrede tusinde personer

Børnedødelighed


FN 3.2.1 Dødelighed hos børn under 5 år
# Import, dødelighed
BEXBBDM1_raw <-
  statgl_url("BEXBBDM1", lang = language) %>% 
  statgl_fetch(
    age       = 0:4,
    type      = "D",
    .col_code = TRUE
    ) %>% 
  as_tibble()

# Import, levendefødte
BEXBBLK1_raw <-
  statgl_url("BEXBBLK1", lang = language) %>%
  statgl_fetch(
    type      = "L",
    .col_code = TRUE
    ) %>% 
  as_tibble()

child_mortality <-
  BEXBBDM1_raw %>% 
  spread(2, 4) %>% 
  spread(1, 3) %>% 
  mutate(sum = `0` + `1` + `2` + `3` + `4`) %>% 
  select(-(2:6)) %>% 
  left_join(BEXBBLK1_raw %>% spread(1, 3)) %>% 
  rename(
    "mortality"  = 2,
    "population" = 3
  ) %>% 
  mutate(rate = mortality / population * 1000,
         time = time %>% make_date())

# Plot
child_mortality %>% 
  ggplot(aes(
    x = time,
    y = rate,
    color = statgl:::statgl_cols("darkblue")
    )) +
  geom_line(size = 2, color = statgl:::statgl_cols("darkblue")) +
  expand_limits(y = 0) +
  theme_statgl() +
  labs(
    title    = sdg3$figs$fig8$title[language],
    subtitle = sdg3$figs$fig8$sub[language],
    x        = " ",
    y        = sdg3$figs$fig8$y_lab[language],
    caption  = sdg3$figs$fig8$cap[language]
  )

Statistikbanken


# Transform
child_mortality <-
  BEXBBDM1_raw %>% 
  spread(2, 4) %>% 
  spread(1, 3) %>% 
  mutate(sum = `0` + `1` + `2` + `3` + `4`) %>% 
  select(-(2:6)) %>% 
  left_join(BEXBBLK1_raw %>% spread(1, 3)) %>% 
  rename(
    "mortality"  = 2,
    "population" = 3
    ) %>% 
  mutate(rate = mortality / population * 1000,
         rate = rate %>% round(3)) %>% 
  select(-(2:3)) %>% 
  arrange(desc(time)) %>% 
  filter(time >= year(Sys.time()) - 5) %>% 
  mutate(time = time %>% factor(levels = unique(time)),
         var = sdg3$figs$fig8$cols$col3[language]) %>% 
  spread(1, 2)

# Table
child_mortality %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  add_footnote(
    sdg3$figs$fig8$foot[language], 
    notation = "symbol"
    )
2021 2020 2019 2018 2017
Børnedødelighed 15,769 11,976 14,134 8,547 8,206
* Dødelighedsrate per tusinde levendefødte

Alkohol og tobak


FN 3.5.2 Tilførsel af alkohol per person over 14 år.
# Import
ALXALK1_raw <-
  statgl_url("ALXALK1", lang = language) %>%
  statgl_fetch(
    unit      = 1,
    type      = 0:2,
    category  = 1,
    .col_code = TRUE
    ) %>% 
  as_tibble()

# Transform
ALXALK1 <-
  ALXALK1_raw %>% 
  mutate(time = time %>% make_date())
  
# Plot
ALXALK1 %>% 
  ggplot(aes(
    x    = time,
    y    = value,
    fill = type
    )) +
  geom_area() +
  theme_statgl() +
  scale_fill_statgl(palette = "autumn") +
  labs(
    title    = sdg3$figs$fig9$title[language],
    subtitle = sdg3$figs$fig9$sub[language],
    x        = " ",
    y        = sdg3$figs$fig9$y_lab[language],
    fill     = sdg3$figs$fig9$fill[language],
    caption  = sdg3$figs$fig9$cap[language]
  )

Statistikbanken

Metode


# Transform
ALXALK1 <-
  ALXALK1_raw %>% 
  arrange(desc(time)) %>% 
  filter(time >= year(Sys.time()) - 5) %>% 
  mutate(time = time %>% factor(levels = unique(time))) %>% 
  spread(4, 5)

# Table
ALXALK1 %>% 
  select(-c(1, 3)) %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  pack_rows(index = table(ALXALK1[[3]]))
2021 2020 2019 2018 2017
Liter pr. person over 14 år
Spiritus 0,87 0,77 0,64 0,65 0,73
Vin 1,66 1,68 1,43 1,33 1,66
Øl 6,15 6,31 5,54 5,45 6,02
FN 3.a.1 Indførsel af cigaretter pr. dag pr. person over 14 år
# Import
ALXTOB2_raw <-
  statgl_url("ALXTOB2", lang = language) %>% 
  statgl_fetch(
    unit      = 3,
    type      = 0:1,
    .col_code = TRUE
    ) %>% 
  as_tibble()

  
# Transform
ALXTOB2 <-
  ALXTOB2_raw %>% 
  mutate(time = time %>% make_date())

# Plot
ALXTOB2 %>% 
  ggplot(aes(
    x    = time,
    y    = value,
    fill = type
    )) +
  geom_area() +
  theme_statgl() +
  theme(plot.margin = margin(10, 10, 10, 10)) +
  scale_fill_statgl(palette = "autumn") +
  scale_y_continuous(labels = scales::comma_format(
    decimal.mark = ",", 
    big.mark     = "."
    )) +
  labs(
    title    = sdg3$figs$fig10$title[language],
    subtitle = sdg3$figs$fig10$sub[language],
    x        = " ",
    y        = sdg3$figs$fig10$y_lab[language],
    fill     = sdg3$figs$fig10$fill[language],
    caption  = sdg3$figs$fig10$cap[language]
  )

Statistikbanken

Metode


# Transform
ALXTOB2 <-
  ALXTOB2_raw %>% 
  arrange(desc(time)) %>% 
  filter(time >= year(Sys.time()) - 5) %>% 
  mutate(time = time %>% factor(levels = unique(time))) %>% 
  spread(2, 4)

# Table
ALXTOB2 %>% 
  select(-1) %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  pack_rows(index = table(ALXTOB2[[1]]))
2021 2020 2019 2018 2017
Antal stk. pr. dag pr. person over 14 år
Almindelige cigaretter 2,82 3,28 2,75 2,98 2,88
Rulletobak 2,35 2,44 2,91 1,86 2,46

Offentligt ansatte i sundhedsvæsenet


FN 3.c.1 Offentligt ansatte i sundhedsvæsenet
# Import
OFXOA1_raw <-
  statgl_url("OFXOA1", lang = language) %>% 
  statgl_fetch(
    `inventory variable` = px_all(),
    .col_code            = TRUE
    ) %>% 
  as_tibble()

# Transform
OFXOA1 <-
  OFXOA1_raw %>% 
  mutate(
    time  = time %>% make_date(),
    value = value * 10^-3
    )

# Plot
OFXOA1 %>% 
  ggplot(aes(
    x    = time,
    y    = value,
    fill = `inventory variable`
  )) +
  geom_col(position = "dodge") +
  theme_statgl() + 
  scale_fill_statgl(reverse = TRUE) +
  labs(
    title   = sdg3$figs$fig11$title[language],
    x       = " ",
    y       = sdg3$figs$fig11$y_lab[language],
    fill    = " ",
    caption = sdg3$figs$fig11$cap[language]
  )

Statistikbanken

Metode


# Transform
OFXOA1 <- 
  OFXOA1_raw %>% 
  arrange(desc(time)) %>% 
  filter(time >= year(Sys.time()) - 5) %>% 
  mutate(time = time %>% factor(levels = unique(time))) %>% 
  spread(1, 3)

# Table
OFXOA1 %>% 
  rename(" " = 1) %>% 
  statgl_table() %>% 
  add_footnote(
    sdg3$figs$fig11$foot[language], 
    notation = "symbol"
    )
2020 2019 2018 2017
Ansatte 18.691 18.976 18.517 18.428
Fuldtidsbeskæftigede 11.066 10.872 10.699 10.536
* Antal personer i sundhedsvæsnet

Fødselsvægt


GS Fødselsvægt
# Import
BEDLL1_raw <- 
  statgl_url("BEXLL1", lang = language) %>% 
  statgl_fetch(
    time      = px_all(),
    weight    = 0:9,
    .col_code = TRUE
  ) %>% 
  as_tibble()

# Transform
BEDLL1 <- 
  BEDLL1_raw %>% 
  mutate(
    time   = time %>% as.numeric(),
    weight = weight %>% str_remove("gram") %>% trimws(),
    weight = weight %>% factor(levels = unique(weight))
  ) %>% 
  filter(time %in% quantile(time)[-1])

# Plot
BEDLL1 %>% 
  ggplot(aes(
    x    = weight,
    y    = value,
    fill = time
  )) +
  geom_col() +
  facet_wrap(~ time) + 
  coord_flip() +
  theme_statgl() + 
  scale_color_statgl() +
  theme(legend.position = "none") +
  labs(
    title   = sdg3$figs$fig12$title[language],
    x       = sdg3$figs$fig12$x_lab[language],
    y       = sdg3$figs$fig12$y_lab[language],
    caption = sdg3$figs$fig12$cap[language]
  )