Back


Goal 12: Responsible consumption and production

Electric cars


GS Eldrevne biler
# Import
url <- paste0("https://bank.stat.gl/api/v1/", language, "/Greenland/EN/EN40/ENXMO5FU.px")

elbiler_raw <- 
  url |>  
  statgl_fetch(
    time      = px_all(),
    category  = px_all(),
    .col_code = T
  ) |> 
  as_tibble()

# Transform
elbiler <- 
  elbiler_raw |> 
  filter(category != elbiler_raw[[1]][1])

# Plot
elbiler %>% 
  ggplot(aes(
    x    = time,
    y    = value,
    fill = category
  )) +
  geom_col() +
  theme_statgl() + 
  scale_fill_statgl(reverse = T) +
  labs(
    title   = sdg13$figs$fig4$title[language],
    y       = sdg13$figs$fig4$y_lab[language],
    x       = " ",
    fill    = " ",
    caption = sdg13$figs$fig4$cap[language]
  )

StatBank


# Table
tab <- 
  elbiler_raw %>% 
  mutate(time = time %>% factor(levels = unique(time))) %>% 
  spread(time, value) %>% 
  mutate(across(2:8 , ~ if_else(is.na(.x), 0, .x)))

tab %>% 
  rename(" " = 1) %>% 
  statgl_table(replace_0s = T) |> 
  row_spec(1, bold = T)
2016 2017 2018 2019 2020 2021 2022 2023 2024
Electric and hybrid cars total 191 341 482 643 977 1.466 1.642 1.995 2.268
Electric cars 191 341 482 643 747 841 727 766 795
Hybrid cars 0 0 0 0 27 71 105 135 160
Hybrid cars with plug-in 0 0 0 0 203 554 810 1.094 1.313