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 2015
Aborter pr. 1000 64,7 66,4 62,3 59,5 59,1
Aldersstandardiseret rate pr. 1000 kvinder, 12-49 år 56,2 57,9 54,5 52,4 53,1
Aborter 902,0 931,0 883,0 855,0 864,0
Middelfolketal 13.941,0 14.019,0 14.169,0 14.364,0 14.626,0

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 2012 - 2016
Middellevetid
0 70,46 70,70 70,63 70,60
1 70,09 70,27 70,22 70,25
# 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
2012 - 2016 70,89 69,02 70,54 68,47

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()
2020 2019 2018 2017 2016 2015
Crude Rate 9,249 9,784 8,712 8,937 8,724 8,445
Std. Rate 5,688 6,073 5,428 5,857 5,726 5,662
# 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 2014
Diagnosticerede tilfælde af tuberkulose
Kvinder 64,2 105,9 113,1
Mænd 148,1 165,8 232,1
* 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