Created
August 1, 2022 01:55
-
-
Save abikoushi/a00026b9988faf5f0cfc893049845310 to your computer and use it in GitHub Desktop.
e-stat API のデモ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(estatapi) | |
library(tidyverse) | |
myappId <-"ここには自分のアプリケーションIDを入れる" | |
dat1 <-estat_getStatsData(appId = myappId, statsDataId = "0000010209") | |
#print(unique(dat1$`I 健康・医療`)) #ほしい項目を目で探す | |
nyuin <-dplyr::filter(dat1,`I 健康・医療`=="#I04103_精神科病院年間新入院患者数(人口10万人当たり)" , | |
地域=="全国") %>% | |
mutate(year=as.integer(substr(調査年,1,4))) | |
theme_set(theme_bw(14,"Osaka")+ | |
theme(axis.text = element_text(colour="black"))) | |
p_nyuin <-ggplot(nyuin,aes(x=year,y=value))+ | |
geom_area(alpha=0.1, colour="black")+ | |
labs(y="人口10万人当たり",x="年")+ | |
ggtitle("精神科病院年間新入院患者数(全国)") | |
ggsave("~/Desktop/p_nyuin.png",p_nyuin) | |
zaiin <-dplyr::filter(dat1,`I 健康・医療`=="#I10205_精神科病院平均在院日数" , | |
地域=="全国") %>% | |
mutate(year=as.integer(substr(調査年,1,4))) | |
head(zaiin$value) | |
p_zaiin <-ggplot(zaiin,aes(x=year,y=value))+ | |
geom_area(alpha=0.1, colour="black")+ | |
labs(y="日",x="年")+ | |
ggtitle("精神科病院平均在院日数(全国)") | |
print(p_zaiin) | |
ggsave("~/Desktop/p_zaiin.png",p_zaiin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment