Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Created April 12, 2020 08:38
Show Gist options
  • Save yutannihilation/9b81647b6ff7e91c0fa71c55661d59ca to your computer and use it in GitHub Desktop.
Save yutannihilation/9b81647b6ff7e91c0fa71c55661d59ca to your computer and use it in GitHub Desktop.
library(estatapi)
#> このサービスは、政府統計総合窓口(e-Stat)のAPI機能を使用していますが、サービスの内容は国によって保証されたものではありません。
library(dplyr, warn.conflicts = FALSE)
library(ggplot2)

d <- estat_getStatsData(appId = keyring::key_get("estatapi"), statsDataId = "0003368797")
#> Fetching record 1-2120... (total: 2120 records)

d %>% 
  filter(
    stringr::str_detect(表章項目, "枝肉の.*価"),
    stringr::str_detect(と畜種類, "")
  ) %>% 
  mutate(year = readr::parse_number(`時間軸(年次)`)) %>% 
  ggplot(aes(year, value, colour = と畜種類)) +
  geom_line() +
  facet_wrap(vars(表章項目), ncol = 1, scales = "free_y") +
  scale_colour_viridis_d(option = "B") +
  theme_minimal()
#> Warning: Removed 2 row(s) containing missing values (geom_path).

Created on 2020-04-12 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment