第7週

02/01(TH)  気候変動に対する対策

       気候変動と貧困の連鎖

第7週は、南部アフリカや南アジアなど気候変動から大きな影響を受けている国々の現状を取り上げます。

02/06 (TU) Rでデータサイエンス7:都市部と農村部の生活状況の格差  [Main]・[授業]・[ビデオ]

Urban and rural development

Access to electricity, urban (% of urban population):EG.ELC.ACCS.UR.ZS [Link]

Access to electricity, rural (% of rural population):EG.ELC.ACCS.RU.ZS [Link]

People using at least basic drinking water services, urban (% of urban population):SH.H2O.BASW.UR.ZS [Link]

People using at least basic sanitation services, rural (% of rural population):SH.STA.BASS.RU.ZS [Link]

People using at least basic sanitation services, urban (% of urban population):SH.STA.BASS.UR.ZS [Link]

People using at least basic drinking water services, rural (% of rural population):SH.H2O.BASW.RU.ZS [Link]

内容

df_service <- WDI(
  indicator = c(electricity_ur = "EG.ELC.ACCS.UR.ZS",
                electricity_ru = "EG.ELC.ACCS.RU.ZS",
                water_ur = "SH.H2O.BASW.UR.ZS",
                water_ru = "SH.H2O.BASW.RU.ZS",
                sanitation_ur = "SH.STA.BASS.UR.ZS",
                sanitation_ru = "SH.STA.BASS.RU.ZS"
                ), extra = TRUE)
write_csv(df_service, "data/service.csv")
df_service <- read_csv("data/service.csv")
Rows: 16758 Columns: 18── Column specification ─────────────────────────────────────────────────
Delimiter: ","
chr  (7): country, iso2c, iso3c, region, capital, income, lending
dbl  (9): year, electricity_ur, electricity_ru, water_ur, water_ru, s...
lgl  (1): status
date (1): lastupdated
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
df_service_long <- df_service |> 
  pivot_longer(7:12, names_to = "name", values_to = "value")
df_service_long |> 
  group_by(year, name) |> drop_na(value) |>
  summarize(num = n()) |> arrange(desc(year))
`summarise()` has grouped output by 'year'. You can override using the `.groups` argument.
df_service_long |> 
  group_by(year, name) |> drop_na(value) |>
  summarize(num = n()) |> 
  ggplot(aes(year, num, col = name)) + geom_line() +
  labs(title = "各指標の年毎のデータ数", y = "データ数", x = "年")
`summarise()` has grouped output by 'year'. You can override using the `.groups` argument.

World Development Indicators: [Link]

df_service_long |> 
  filter(name %in% c("electricity_ur", "electricity_ru")) |>
  filter(iso2c %in% c("1W", "ZF", "T6")) |> drop_na(value) |>
  ggplot(aes(year, value, col = name, linetype = iso2c)) + geom_line()

df_service_long |> 
  filter(iso2c %in% c("1W", "ZF", "T6")) |> drop_na(value) |>
  ggplot(aes(year, value, col = name, linetype = iso2c)) + geom_line()

LS0tCnRpdGxlOiAiR0VTIDAwMSDmvJTnv5I3IgphdXRob3I6ICJILiBTdXp1a2kiCmRhdGU6ICJgciBTeXMuRGF0ZSgpYCIKb3V0cHV0OgogIGh0bWxfbm90ZWJvb2s6IGRlZmF1bHQKLS0tCgojIyDnrKw36YCxCgowMi8wMShUSCkg44CA5rCX5YCZ5aSJ5YuV44Gr5a++44GZ44KL5a++562WCgrjgIDjgIDjgIDjgIDjgIDjgIAg5rCX5YCZ5aSJ5YuV44Go6LKn5Zuw44Gu6YCj6Y6WCgrnrKw36YCx44Gv44CB5Y2X6YOo44Ki44OV44Oq44Kr44KE5Y2X44Ki44K444Ki44Gq44Gp5rCX5YCZ5aSJ5YuV44GL44KJ5aSn44GN44Gq5b2x6Z+/44KS5Y+X44GR44Gm44GE44KL5Zu944CF44Gu54++54q244KS5Y+W44KK5LiK44GS44G+44GZ44CCCgowMi8wNiAoVFUp44CAUuOBp+ODh+ODvOOCv+OCteOCpOOCqOODs+OCuTfvvJrpg73luILpg6jjgajovrLmnZHpg6jjga7nlJ/mtLvnirbms4Hjga7moLzlt67jgIAgW1tNYWluXShodHRwczovL2RzLXNsLmdpdGh1Yi5pby9pbnRybzJyL2dlczAwMS9nZXMwMDEtbWFpbi5uYi5odG1sKV3jg7tbW+aOiOalrV0oaHR0cHM6Ly9kcy1zbC5naXRodWIuaW8vaW50cm8yci9nZXMwMDEvZ2VzMDAxMjAubmIuaHRtbCld44O7W1vjg5Pjg4fjgqpdKGh0dHBzOi8veW91d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