-
Notifications
You must be signed in to change notification settings - Fork 1
/
w5eda1.Rmd
306 lines (172 loc) · 6.74 KB
/
w5eda1.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
---
title: "探索的データ分析 - EDA 1"
author: "ID, Last, First"
date: "2024年1月23日"
output:
html_notebook: default
---
## 課題
以下の指標の中から、一つを選択して、データの概要(description)を記録し、データを WDI で取得し、以下の分析をする。
1. 各年毎のデータの数の棒グラフ
2. 日本のデータの年の降順での表示
3. 経年変化を表す折れ線グラフ
a. 日本
b. 南部アフリカ関税同盟の5カ国
c. 選択したいくつかの国
4. データが十分ある最近の年の値のヒストグラム
5. データが十分ある最近の年の値の10カ国の値の棒グラフ
a. 値が大きい方から
b. 値が小さい方から
それぞれについて考察(気づいたこと、疑問など)を記す
**2023.1.27. 23:59** までに Moodle の演習の課題ボックスに提出したものについては、なるべく、早く見て、フィードバックを書きます。それ以降に提出されたものも見ますが、フィードバックは遅くなると思ってください。
### データ
1. School enrollment, primary (% gross):SE.PRM.ENRR [[Link](https://data.worldbank.org/indicator/SE.PRM.ENRR)] 変数名:`primary`
2. School enrollment, secondary (% gross):SE.SEC.ENRR [[Link](https://data.worldbank.org/indicator/SE.SEC.ENRR)] 変数名:`secondary`
3. School enrollment, tertiary (% gross):SE.TER.ENRR [[Link](https://data.worldbank.org/indicator/SE.TER.ENRR)] 変数名:`tertiary`
4. Mortality rate, under-5 (per 1,000 live births):SH.DYN.MORT [[Link](https://databank.worldbank.org/metadataglossary/world-development-indicators/series/SH.DYN.MORT)] 変数名:`under5`
5. Incidence of HIV (% of uninfected population ages 15-49):SH.HIV.INCD.ZS [[Link](https://data.worldbank.org/indicator/SH.HIV.INCD.ZS?locations=SZ)] 変数名:`hiv`
6. School enrollment, primary and secondary (gross), gender parity index (GPI):SE.ENR.PRSC.FM.ZS [[Link](https://data.worldbank.org/indicator/SE.ENR.PRSC.FM.ZS)] 変数名:`school_gpi`
7. Ratio of female to male labor force participation rate (%) (modeled ILO estimate):SL.TLF.CACT.FM.ZS [[Link](https://data.worldbank.org/indicator/SL.TLF.CACT.FM.ZS)] 変数名:`job_gpi`
8. Unemployment, female (% of female labor force) (modeled ILO estimate):SL.UEM.TOTL.FE.ZS [[Link](https://data.worldbank.org/indicator/SL.UEM.TOTL.FE.ZS)] 変数名:`female_unemploy`
9. Unemployment, male (% of male labor force) (modeled ILO estimate):SL.UEM.TOTL.MA.ZS [[Link](https://data.worldbank.org/indicator/SL.UEM.TOTL.MA.ZS)] 変数名:`male_unemploy`
10. Net official development assistance and official aid received (current US\$) DT.ODA.ALLD.CD [[Link](https://data.worldbank.org/indicator/DT.ODA.ALLD.CD)] 変数名:`oda`
# 表題
> 概要:
## データ
-
- Description
### データ情報
- データ名:
- データコード:
- 変数名:
- 概要:
### データの取得
#### 準備
```{r}
library(tidyverse)
library(WDI)
```
WDI パッケージを使って、直接データをダウンロード
```{r eval = FALSE}
```
```{r eval = FALSE}
```
```{r}
```
### データの確認
```{r}
```
```{r}
```
```{r}
REGION <- c("1A", "1W", "4E", "7E", "8S", "B8", "EU", "F1", "OE", "S1",
"S2", "S3", "S4", "T2", "T3", "T4", "T5", "T6", "T7", "V1", "V2",
"V3", "V4", "XC", "XD", "XE", "XF", "XG", "XH", "XI", "XJ", "XL",
"XM", "XN", "XO", "XP", "XQ", "XT", "XU", "XY", "Z4", "Z7", "ZF",
"ZG", "ZH", "ZI", "ZJ", "ZQ", "ZT")
```
```{r}
```
```{r}
```
### 分析する国のリスト
#### **南部アフリカ関税同盟** The Southern African Customs Union (SACU)
```{r}
SOUTH_AFRICA_FIVE <- c("South Africa", "Namibia", "Eswatini", "Botswana", "Lesotho")
```
#### いくつかの国を選択
```{r}
```
## 分析
### 1. 各年毎のデータの数の棒グラフ
```{r}
```
**気づいたこと・疑問**
-
## 視覚化
### 2. 日本
```{r}
```
**気づいたこと・疑問**
-
### 3. 経年変化
#### a. 日本
```{r}
```
**気づいたこと・疑問**
-
#### b. 南部アフリカ関税同盟
```{r}
```
**気づいたこと・疑問**
-
**参考:平均的な値を曲線で表すことも可能です。loess を使うと滑らかな曲線で近似してくれます。**
```{r}
```
**気づいたこと・疑問**
-
#### c. 選択した国・地域
```{r}
```
**気づいたこと・疑問**
-
**参考:平均的な値を曲線で表すことも可能です。loess を使うと滑らかな曲線で近似してくれます。**
```
df_under_6.85 |> filter(country %in% CHOSEN_COUNTRIES) |> drop_na(under_6.85) |>
ggplot(aes(year, under_6.85)) + geom_line(aes(col = country)) +
geom_smooth(formula = 'y~x', method = "loess", se = FALSE)
```
```{r}
```
**気づいたこと・疑問**
-
### 分布
データの数から、まずは、2020年について見てみる。
```{r}
```
**気づいたこと・疑問**
-
**参考:**SACU の5カ国の値を縦線で書き込むには下のようにします。
```
df_under_6.85 |> filter(year == 2010) |> filter(country %in% SOUTH_AFRICA_FIVE)
```
```{r}
```
**参考:日本と**SACU の5カ国の値を縦線で書き込むには下のようにします。
```
JP <- 0.5
SAF <- df_under_6.85 |> filter(year == 2010) |> filter(country %in% SOUTH_AFRICA_FIVE) |> pull(under_6.85)
df_under_6.85 |> filter(year == 2010) |> filter(!(country %in% REGION))|>
drop_na(under_6.85) |>
ggplot() + geom_histogram(aes(under_6.85), binwidth = 1) +
geom_vline(xintercept = SAF, col = "red") + geom_vline(xintercept = JP, col = "blue") +labs(title = "貧困率(1日6.85ドル以下)", subtitle = "日本:青、SACU:赤")
```
```{r}
```
**気づいたこと・疑問**
-
### データが十分ある最近の年の値の10カ国の値の棒グラフ
#### a. 値が大きい方から
```
df_under_6.85 |> filter(year == 2019) |> drop_na(under_6.85) |>
filter(!(iso2c %in% REGION))|>
arrange(desc(under_6.85)) |> head(10) |>
ggplot(aes(fct_reorder(country, under_6.85), ed_exp)) + geom_col() +
coord_flip() + labs(title = "Top 10 Countries", x = "country", y = "poverty rate (under $6.85 per day)")
```
```{r}
```
**気づいたこと・疑問**
-
#### b. 値が小さい方から
```
df_under_6.85 |> filter(year == 2019) |> drop_na(under_6.85) |>
filter(!(iso2c %in% REGION))|>
arrange(under_6.85) |> head(10) |>
ggplot(aes(fct_rev(fct_reorder(country, under_6.85)), under_6.85)) + geom_col() +
coord_flip() + labs(title = "Lowest 10 Countries", x = "country", y = "poverty rate (under $6.85 per day))
```
```{r}
```
**気づいたこと・疑問**
-