Challenge 10

Author

Jingyi Yang

knitr::opts_chunk$set(echo = TRUE)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(here)
here() starts at C:/8-601
library(readr)
library(readxl)
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(purrr)

1. Import and clean the data set

data_import_FAOSATA <- function(df) {
  
  setwd("C:\\8-601\\challenge_datasets")
  p<- read_csv(df)%>%
    select(-contains("Code"))%>%
    filter(Flag!="A")%>%
   select(-contains("Flag"))%>%
   filter(!is.na(Value))
  
  return(p)

}

FAOSATA_files<-list.files(path="C:\\8-601\\challenge_datasets", pattern="FAOSTAT")
FAOSATA_files<- FAOSATA_files[!FAOSATA_files=="FAOSTAT_country_groups.csv"]       

FAOSATA_files
[1] "FAOSTAT_cattle_dairy.csv" "FAOSTAT_egg_chicken.csv" 
[3] "FAOSTAT_livestock.csv"   
map(FAOSATA_files, data_import_FAOSATA)
Rows: 36449 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Domain Code, Domain, Area, Element, Item, Unit, Flag, Flag Description
dbl (6): Area Code, Element Code, Item Code, Year Code, Year, Value

ℹ 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.
Rows: 38170 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Domain Code, Domain, Area, Element, Item, Unit, Flag, Flag Description
dbl (6): Area Code, Element Code, Item Code, Year Code, Year, Value

ℹ 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.
Rows: 82116 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Domain Code, Domain, Area, Element, Item, Unit, Flag, Flag Description
dbl (6): Area Code, Element Code, Item Code, Year Code, Year, Value

ℹ 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.
[[1]]
# A tibble: 23,261 × 7
   Domain            Area        Element      Item             Year Unit   Value
   <chr>             <chr>       <chr>        <chr>           <dbl> <chr>  <dbl>
 1 Livestock Primary Afghanistan Milk Animals Milk, whole fr…  1961 Head  700000
 2 Livestock Primary Afghanistan Yield        Milk, whole fr…  1961 hg/An   5000
 3 Livestock Primary Afghanistan Production   Milk, whole fr…  1961 tonn… 350000
 4 Livestock Primary Afghanistan Milk Animals Milk, whole fr…  1962 Head  700000
 5 Livestock Primary Afghanistan Yield        Milk, whole fr…  1962 hg/An   5000
 6 Livestock Primary Afghanistan Production   Milk, whole fr…  1962 tonn… 350000
 7 Livestock Primary Afghanistan Milk Animals Milk, whole fr…  1963 Head  780000
 8 Livestock Primary Afghanistan Yield        Milk, whole fr…  1963 hg/An   5128
 9 Livestock Primary Afghanistan Production   Milk, whole fr…  1963 tonn… 400000
10 Livestock Primary Afghanistan Milk Animals Milk, whole fr…  1964 Head  780000
# ℹ 23,251 more rows

[[2]]
# A tibble: 27,396 × 7
   Domain            Area        Element    Item                Year Unit  Value
   <chr>             <chr>       <chr>      <chr>              <dbl> <chr> <dbl>
 1 Livestock Primary Afghanistan Laying     Eggs, hen, in she…  1961 1000…  4000
 2 Livestock Primary Afghanistan Yield      Eggs, hen, in she…  1961 100m… 25000
 3 Livestock Primary Afghanistan Production Eggs, hen, in she…  1961 tonn… 10000
 4 Livestock Primary Afghanistan Laying     Eggs, hen, in she…  1962 1000…  4400
 5 Livestock Primary Afghanistan Yield      Eggs, hen, in she…  1962 100m… 25000
 6 Livestock Primary Afghanistan Production Eggs, hen, in she…  1962 tonn… 11000
 7 Livestock Primary Afghanistan Laying     Eggs, hen, in she…  1963 1000…  4600
 8 Livestock Primary Afghanistan Yield      Eggs, hen, in she…  1963 100m… 25000
 9 Livestock Primary Afghanistan Production Eggs, hen, in she…  1963 tonn… 11500
10 Livestock Primary Afghanistan Laying     Eggs, hen, in she…  1964 1000…  4800
# ℹ 27,386 more rows

[[3]]
# A tibble: 30,094 × 7
   Domain       Area        Element Item   Year Unit    Value
   <chr>        <chr>       <chr>   <chr> <dbl> <chr>   <dbl>
 1 Live Animals Afghanistan Stocks  Asses  1964 Head  1150000
 2 Live Animals Afghanistan Stocks  Asses  1973 Head  1250000
 3 Live Animals Afghanistan Stocks  Asses  1974 Head  1250000
 4 Live Animals Afghanistan Stocks  Asses  1975 Head  1250000
 5 Live Animals Afghanistan Stocks  Asses  1976 Head  1250000
 6 Live Animals Afghanistan Stocks  Asses  1978 Head  1300000
 7 Live Animals Afghanistan Stocks  Asses  1979 Head  1300000
 8 Live Animals Afghanistan Stocks  Asses  1980 Head  1295000
 9 Live Animals Afghanistan Stocks  Asses  1981 Head  1315000
10 Live Animals Afghanistan Stocks  Asses  1982 Head  1315000
# ℹ 30,084 more rows
FAOSATA_data<- map_dfr(FAOSATA_files, data_import_FAOSATA)
Rows: 36449 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Domain Code, Domain, Area, Element, Item, Unit, Flag, Flag Description
dbl (6): Area Code, Element Code, Item Code, Year Code, Year, Value

ℹ 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.
Rows: 38170 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Domain Code, Domain, Area, Element, Item, Unit, Flag, Flag Description
dbl (6): Area Code, Element Code, Item Code, Year Code, Year, Value

ℹ 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.
Rows: 82116 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Domain Code, Domain, Area, Element, Item, Unit, Flag, Flag Description
dbl (6): Area Code, Element Code, Item Code, Year Code, Year, Value

ℹ 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.
FAOSATA_data
# A tibble: 80,751 × 7
   Domain            Area        Element      Item             Year Unit   Value
   <chr>             <chr>       <chr>        <chr>           <dbl> <chr>  <dbl>
 1 Livestock Primary Afghanistan Milk Animals Milk, whole fr…  1961 Head  700000
 2 Livestock Primary Afghanistan Yield        Milk, whole fr…  1961 hg/An   5000
 3 Livestock Primary Afghanistan Production   Milk, whole fr…  1961 tonn… 350000
 4 Livestock Primary Afghanistan Milk Animals Milk, whole fr…  1962 Head  700000
 5 Livestock Primary Afghanistan Yield        Milk, whole fr…  1962 hg/An   5000
 6 Livestock Primary Afghanistan Production   Milk, whole fr…  1962 tonn… 350000
 7 Livestock Primary Afghanistan Milk Animals Milk, whole fr…  1963 Head  780000
 8 Livestock Primary Afghanistan Yield        Milk, whole fr…  1963 hg/An   5128
 9 Livestock Primary Afghanistan Production   Milk, whole fr…  1963 tonn… 400000
10 Livestock Primary Afghanistan Milk Animals Milk, whole fr…  1964 Head  780000
# ℹ 80,741 more rows

2. Data summary

2.1 Data summary- Characteristic

summary_characteristcs<-function(x) {
  
freq_table <- table(x)%>% as.data.frame()%>% rename(Number=Freq)

prop_table <- table(x) %>% prop.table()%>% as.data.frame()

table <- left_join(freq_table,prop_table)

return(table)

  
}

character <- FAOSATA_data%>%
  select(where(is.character))
 
map(character, summary_characteristcs)
Joining with `by = join_by(x)`
Joining with `by = join_by(x)`
Joining with `by = join_by(x)`
Joining with `by = join_by(x)`
Joining with `by = join_by(x)`
$Domain
                  x Number      Freq
1      Live Animals  30094 0.3726765
2 Livestock Primary  50657 0.6273235

$Area
                                                       x Number         Freq
1                                            Afghanistan    484 5.993734e-03
2                                                 Africa    116 1.436515e-03
3                                                Albania    424 5.250709e-03
4                                                Algeria    331 4.099020e-03
5                                         American Samoa    446 5.523151e-03
6                                               Americas    116 1.436515e-03
7                                                 Angola    620 7.677923e-03
8                                    Antigua and Barbuda    643 7.962750e-03
9                                              Argentina    464 5.746059e-03
10                                               Armenia    103 1.275526e-03
11                                                  Asia    116 1.436515e-03
12                                             Australia    282 3.492217e-03
13                             Australia and New Zealand    116 1.436515e-03
14                                               Austria    135 1.671806e-03
15                                            Azerbaijan     56 6.934899e-04
16                                               Bahamas    528 6.538619e-03
17                                               Bahrain    466 5.770826e-03
18                                            Bangladesh    387 4.792510e-03
19                                              Barbados    594 7.355946e-03
20                                               Belarus    124 1.535585e-03
21                                               Belgium     72 8.916298e-04
22                                    Belgium-Luxembourg     82 1.015467e-03
23                                                Belize    473 5.857513e-03
24                                                 Benin    346 4.284777e-03
25                                               Bermuda    512 6.340479e-03
26                                                Bhutan    622 7.702691e-03
27                      Bolivia (Plurinational State of)    473 5.857513e-03
28                                Bosnia and Herzegovina    175 2.167156e-03
29                                              Botswana    494 6.117571e-03
30                                                Brazil    325 4.024718e-03
31                                British Virgin Islands    373 4.619138e-03
32                                     Brunei Darussalam    316 3.913264e-03
33                                              Bulgaria    158 1.956632e-03
34                                          Burkina Faso    433 5.362163e-03
35                                               Burundi    340 4.210474e-03
36                                            Cabo Verde    526 6.513851e-03
37                                              Cambodia    442 5.473616e-03
38                                              Cameroon    566 7.009201e-03
39                                                Canada    303 3.752276e-03
40                                             Caribbean    116 1.436515e-03
41                                        Cayman Islands    235 2.910181e-03
42                              Central African Republic    433 5.362163e-03
43                                       Central America    116 1.436515e-03
44                                          Central Asia     54 6.687224e-04
45                                                  Chad    579 7.170190e-03
46                                                 Chile    432 5.349779e-03
47                                  China, Hong Kong SAR    380 4.705824e-03
48                                      China, Macao SAR    174 2.154772e-03
49                                       China, mainland    346 4.284777e-03
50                             China, Taiwan Province of    192 2.377680e-03
51                                              Colombia    373 4.619138e-03
52                                               Comoros    555 6.872980e-03
53                                                 Congo    519 6.427165e-03
54                                          Cook Islands    315 3.900880e-03
55                                            Costa Rica    522 6.464316e-03
56                                         Côte d'Ivoire    333 4.123788e-03
57                                               Croatia     74 9.163973e-04
58                                                  Cuba    263 3.256926e-03
59                                                Cyprus    334 4.136172e-03
60                                               Czechia     61 7.554086e-04
61                                        Czechoslovakia     87 1.077386e-03
62                 Democratic People's Republic of Korea    551 6.823445e-03
63                      Democratic Republic of the Congo    379 4.693440e-03
64                                               Denmark    108 1.337445e-03
65                                              Djibouti    430 5.325011e-03
66                                              Dominica    567 7.021585e-03
67                                    Dominican Republic    591 7.318795e-03
68                                        Eastern Africa    116 1.436515e-03
69                                          Eastern Asia    116 1.436515e-03
70                                        Eastern Europe    116 1.436515e-03
71                                               Ecuador    283 3.504601e-03
72                                                 Egypt    329 4.074253e-03
73                                           El Salvador    467 5.783210e-03
74                                     Equatorial Guinea    388 4.804894e-03
75                                               Eritrea    248 3.071169e-03
76                                               Estonia     64 7.925598e-04
77                                              Eswatini    487 6.030885e-03
78                                              Ethiopia    217 2.687273e-03
79                                          Ethiopia PDR    310 3.838962e-03
80                                                Europe    116 1.436515e-03
81                           Falkland Islands (Malvinas)    244 3.021634e-03
82                                         Faroe Islands     46 5.696524e-04
83                                                  Fiji    490 6.068036e-03
84                                               Finland    141 1.746108e-03
85                                                France    196 2.427215e-03
86                                         French Guyana    402 4.978267e-03
87                                      French Polynesia    515 6.377630e-03
88                                                 Gabon    504 6.241409e-03
89                                                Gambia    519 6.427165e-03
90                                               Georgia    155 1.919481e-03
91                                               Germany    134 1.659422e-03
92                                                 Ghana    478 5.919431e-03
93                                                Greece    176 2.179540e-03
94                                             Greenland     46 5.696524e-04
95                                               Grenada    697 8.631472e-03
96                                            Guadeloupe    499 6.179490e-03
97                                                  Guam    279 3.455066e-03
98                                             Guatemala    429 5.312628e-03
99                                                Guinea    525 6.501467e-03
100                                        Guinea-Bissau    644 7.975133e-03
101                                               Guyana    639 7.913215e-03
102                                                Haiti    723 8.953449e-03
103                                             Honduras    543 6.724375e-03
104                                              Hungary    237 2.934948e-03
105                                              Iceland    176 2.179540e-03
106                                                India    582 7.207341e-03
107                                            Indonesia    176 2.179540e-03
108                           Iran (Islamic Republic of)    484 5.993734e-03
109                                                 Iraq    637 7.888447e-03
110                                              Ireland    282 3.492217e-03
111                                               Israel    375 4.643905e-03
112                                                Italy    227 2.811111e-03
113                                              Jamaica    657 8.136122e-03
114                                                Japan    183 2.266226e-03
115                                               Jordan    356 4.408614e-03
116                                           Kazakhstan    138 1.708957e-03
117                                                Kenya    428 5.300244e-03
118                                             Kiribati    215 2.662506e-03
119                                               Kuwait    292 3.616054e-03
120                                           Kyrgyzstan    145 1.795643e-03
121                     Lao People's Democratic Republic    432 5.349779e-03
122                                               Latvia     69 8.544786e-04
123                                              Lebanon    471 5.832745e-03
124                                              Lesotho    437 5.411698e-03
125                                              Liberia    578 7.157806e-03
126                                                Libya    441 5.461233e-03
127                                        Liechtenstein    238 2.947332e-03
128                                            Lithuania     69 8.544786e-04
129                                           Luxembourg     38 4.705824e-04
130                                           Madagascar    492 6.092804e-03
131                                               Malawi    389 4.817278e-03
132                                             Malaysia    358 4.433382e-03
133                                                 Mali    413 5.114488e-03
134                                                Malta    377 4.668673e-03
135                                           Martinique    402 4.978267e-03
136                                           Mauritania    541 6.699607e-03
137                                            Mauritius    597 7.393097e-03
138                                            Melanesia    116 1.436515e-03
139                                               Mexico    304 3.764659e-03
140                                           Micronesia     58 7.182574e-04
141                     Micronesia (Federated States of)    168 2.080470e-03
142                                        Middle Africa    116 1.436515e-03
143                                             Mongolia    194 2.402447e-03
144                                           Montenegro     54 6.687224e-04
145                                           Montserrat    619 7.665540e-03
146                                              Morocco    385 4.767743e-03
147                                           Mozambique    509 6.303328e-03
148                                              Myanmar    341 4.222858e-03
149                                              Namibia    586 7.256876e-03
150                                                Nauru    232 2.873029e-03
151                                                Nepal    329 4.074253e-03
152                                          Netherlands    171 2.117621e-03
153                        Netherlands Antilles (former)    638 7.900831e-03
154                                        New Caledonia    460 5.696524e-03
155                                          New Zealand    191 2.365296e-03
156                                            Nicaragua    600 7.430249e-03
157                                                Niger    387 4.792510e-03
158                                              Nigeria    480 5.944199e-03
159                                                 Niue    420 5.201174e-03
160                                       Norfolk Island      5 6.191874e-05
161                                      North Macedonia    103 1.275526e-03
162                                      Northern Africa    116 1.436515e-03
163                                     Northern America    116 1.436515e-03
164                                      Northern Europe    116 1.436515e-03
165                                               Norway    142 1.758492e-03
166                                              Oceania    116 1.436515e-03
167                                                 Oman    466 5.770826e-03
168                      Pacific Islands Trust Territory    166 2.055702e-03
169                                             Pakistan    298 3.690357e-03
170                                            Palestine    117 1.448898e-03
171                                               Panama    338 4.185707e-03
172                                     Papua New Guinea    515 6.377630e-03
173                                             Paraguay    422 5.225941e-03
174                                                 Peru    312 3.863729e-03
175                                          Philippines    391 4.842045e-03
176                                               Poland    134 1.659422e-03
177                                            Polynesia    116 1.436515e-03
178                                             Portugal    423 5.238325e-03
179                                          Puerto Rico    490 6.068036e-03
180                                                Qatar    316 3.913264e-03
181                                    Republic of Korea    207 2.563436e-03
182                                  Republic of Moldova     85 1.052619e-03
183                                              Réunion    387 4.792510e-03
184                                              Romania    219 2.712041e-03
185                                   Russian Federation     95 1.176456e-03
186                                               Rwanda    352 4.359079e-03
187         Saint Helena, Ascension and Tristan da Cunha    233 2.885413e-03
188                                Saint Kitts and Nevis    338 4.185707e-03
189                                          Saint Lucia    660 8.173273e-03
190                            Saint Pierre and Miquelon    142 1.758492e-03
191                     Saint Vincent and the Grenadines    547 6.773910e-03
192                                                Samoa    465 5.758443e-03
193                                Sao Tome and Principe    640 7.925598e-03
194                                         Saudi Arabia    374 4.631522e-03
195                                              Senegal    289 3.578903e-03
196                                               Serbia     27 3.343612e-04
197                                Serbia and Montenegro     32 3.962799e-04
198                                           Seychelles    457 5.659373e-03
199                                         Sierra Leone    532 6.588154e-03
200                                            Singapore    230 2.848262e-03
201                                             Slovakia     52 6.439549e-04
202                                             Slovenia     66 8.173273e-04
203                                      Solomon Islands    499 6.179490e-03
204                                              Somalia    738 9.139206e-03
205                                   South-eastern Asia    116 1.436515e-03
206                                         South Africa    391 4.842045e-03
207                                        South America    116 1.436515e-03
208                                          South Sudan     42 5.201174e-04
209                                      Southern Africa    116 1.436515e-03
210                                        Southern Asia    116 1.436515e-03
211                                      Southern Europe    116 1.436515e-03
212                                                Spain    176 2.179540e-03
213                                            Sri Lanka    206 2.551052e-03
214                                                Sudan     27 3.343612e-04
215                                       Sudan (former)    411 5.089720e-03
216                                             Suriname    315 3.900880e-03
217                                               Sweden    146 1.808027e-03
218                                          Switzerland    176 2.179540e-03
219                                 Syrian Arab Republic    236 2.922564e-03
220                                           Tajikistan    133 1.647038e-03
221                                             Thailand    410 5.077337e-03
222                                          Timor-Leste    278 3.442682e-03
223                                                 Togo    448 5.547919e-03
224                                              Tokelau    228 2.823494e-03
225                                                Tonga    462 5.721291e-03
226                                  Trinidad and Tobago    690 8.544786e-03
227                                              Tunisia    537 6.650072e-03
228                                               Turkey    170 2.105237e-03
229                                         Turkmenistan    281 3.479833e-03
230                                               Tuvalu    215 2.662506e-03
231                                               Uganda    403 4.990650e-03
232                                              Ukraine    100 1.238375e-03
233                                 United Arab Emirates    399 4.941115e-03
234 United Kingdom of Great Britain and Northern Ireland    150 1.857562e-03
235                          United Republic of Tanzania    447 5.535535e-03
236                             United States of America    290 3.591287e-03
237                         United States Virgin Islands    491 6.080420e-03
238                                              Uruguay    444 5.498384e-03
239                                                 USSR    129 1.597503e-03
240                                           Uzbekistan    107 1.325061e-03
241                                              Vanuatu    529 6.551002e-03
242                   Venezuela (Bolivarian Republic of)    383 4.742975e-03
243                                             Viet Nam    332 4.111404e-03
244                            Wallis and Futuna Islands    557 6.897747e-03
245                                       Western Africa    116 1.436515e-03
246                                         Western Asia    116 1.436515e-03
247                                       Western Europe    116 1.436515e-03
248                                       Western Sahara    183 2.266226e-03
249                                                World    116 1.436515e-03
250                                                Yemen    449 5.560303e-03
251                                         Yugoslav SFR    117 1.448898e-03
252                                               Zambia    533 6.600537e-03
253                                             Zimbabwe    530 6.563386e-03

$Element
             x Number       Freq
1       Laying   8034 0.09949103
2 Milk Animals   6296 0.07796807
3   Production  11555 0.14309420
4       Stocks  30094 0.37267650
5        Yield  24772 0.30677019

$Item
                       x Number        Freq
1                  Asses   4760 0.058946638
2              Buffaloes    648 0.008024668
3                 Camels   1018 0.012606655
4                 Cattle   3388 0.041956137
5    Eggs, hen, in shell  27396 0.339265148
6                  Goats   4484 0.055528724
7                 Horses   4838 0.059912571
8  Milk, whole fresh cow  23261 0.288058352
9                  Mules   3277 0.040581541
10                  Pigs   3995 0.049473072
11                 Sheep   3686 0.045646494

$Unit
          x Number       Freq
1 1000 Head   8034 0.09949103
2  100mg/An  12651 0.15666679
3      Head  36390 0.45064457
4     hg/An  12121 0.15010340
5    tonnes  11555 0.14309420
 map_dfr(character, summary_characteristcs)
Joining with `by = join_by(x)`
Joining with `by = join_by(x)`
Joining with `by = join_by(x)`
Joining with `by = join_by(x)`
Joining with `by = join_by(x)`
                                                       x Number         Freq
1                                           Live Animals  30094 3.726765e-01
2                                      Livestock Primary  50657 6.273235e-01
3                                            Afghanistan    484 5.993734e-03
4                                                 Africa    116 1.436515e-03
5                                                Albania    424 5.250709e-03
6                                                Algeria    331 4.099020e-03
7                                         American Samoa    446 5.523151e-03
8                                               Americas    116 1.436515e-03
9                                                 Angola    620 7.677923e-03
10                                   Antigua and Barbuda    643 7.962750e-03
11                                             Argentina    464 5.746059e-03
12                                               Armenia    103 1.275526e-03
13                                                  Asia    116 1.436515e-03
14                                             Australia    282 3.492217e-03
15                             Australia and New Zealand    116 1.436515e-03
16                                               Austria    135 1.671806e-03
17                                            Azerbaijan     56 6.934899e-04
18                                               Bahamas    528 6.538619e-03
19                                               Bahrain    466 5.770826e-03
20                                            Bangladesh    387 4.792510e-03
21                                              Barbados    594 7.355946e-03
22                                               Belarus    124 1.535585e-03
23                                               Belgium     72 8.916298e-04
24                                    Belgium-Luxembourg     82 1.015467e-03
25                                                Belize    473 5.857513e-03
26                                                 Benin    346 4.284777e-03
27                                               Bermuda    512 6.340479e-03
28                                                Bhutan    622 7.702691e-03
29                      Bolivia (Plurinational State of)    473 5.857513e-03
30                                Bosnia and Herzegovina    175 2.167156e-03
31                                              Botswana    494 6.117571e-03
32                                                Brazil    325 4.024718e-03
33                                British Virgin Islands    373 4.619138e-03
34                                     Brunei Darussalam    316 3.913264e-03
35                                              Bulgaria    158 1.956632e-03
36                                          Burkina Faso    433 5.362163e-03
37                                               Burundi    340 4.210474e-03
38                                            Cabo Verde    526 6.513851e-03
39                                              Cambodia    442 5.473616e-03
40                                              Cameroon    566 7.009201e-03
41                                                Canada    303 3.752276e-03
42                                             Caribbean    116 1.436515e-03
43                                        Cayman Islands    235 2.910181e-03
44                              Central African Republic    433 5.362163e-03
45                                       Central America    116 1.436515e-03
46                                          Central Asia     54 6.687224e-04
47                                                  Chad    579 7.170190e-03
48                                                 Chile    432 5.349779e-03
49                                  China, Hong Kong SAR    380 4.705824e-03
50                                      China, Macao SAR    174 2.154772e-03
51                                       China, mainland    346 4.284777e-03
52                             China, Taiwan Province of    192 2.377680e-03
53                                              Colombia    373 4.619138e-03
54                                               Comoros    555 6.872980e-03
55                                                 Congo    519 6.427165e-03
56                                          Cook Islands    315 3.900880e-03
57                                            Costa Rica    522 6.464316e-03
58                                         Côte d'Ivoire    333 4.123788e-03
59                                               Croatia     74 9.163973e-04
60                                                  Cuba    263 3.256926e-03
61                                                Cyprus    334 4.136172e-03
62                                               Czechia     61 7.554086e-04
63                                        Czechoslovakia     87 1.077386e-03
64                 Democratic People's Republic of Korea    551 6.823445e-03
65                      Democratic Republic of the Congo    379 4.693440e-03
66                                               Denmark    108 1.337445e-03
67                                              Djibouti    430 5.325011e-03
68                                              Dominica    567 7.021585e-03
69                                    Dominican Republic    591 7.318795e-03
70                                        Eastern Africa    116 1.436515e-03
71                                          Eastern Asia    116 1.436515e-03
72                                        Eastern Europe    116 1.436515e-03
73                                               Ecuador    283 3.504601e-03
74                                                 Egypt    329 4.074253e-03
75                                           El Salvador    467 5.783210e-03
76                                     Equatorial Guinea    388 4.804894e-03
77                                               Eritrea    248 3.071169e-03
78                                               Estonia     64 7.925598e-04
79                                              Eswatini    487 6.030885e-03
80                                              Ethiopia    217 2.687273e-03
81                                          Ethiopia PDR    310 3.838962e-03
82                                                Europe    116 1.436515e-03
83                           Falkland Islands (Malvinas)    244 3.021634e-03
84                                         Faroe Islands     46 5.696524e-04
85                                                  Fiji    490 6.068036e-03
86                                               Finland    141 1.746108e-03
87                                                France    196 2.427215e-03
88                                         French Guyana    402 4.978267e-03
89                                      French Polynesia    515 6.377630e-03
90                                                 Gabon    504 6.241409e-03
91                                                Gambia    519 6.427165e-03
92                                               Georgia    155 1.919481e-03
93                                               Germany    134 1.659422e-03
94                                                 Ghana    478 5.919431e-03
95                                                Greece    176 2.179540e-03
96                                             Greenland     46 5.696524e-04
97                                               Grenada    697 8.631472e-03
98                                            Guadeloupe    499 6.179490e-03
99                                                  Guam    279 3.455066e-03
100                                            Guatemala    429 5.312628e-03
101                                               Guinea    525 6.501467e-03
102                                        Guinea-Bissau    644 7.975133e-03
103                                               Guyana    639 7.913215e-03
104                                                Haiti    723 8.953449e-03
105                                             Honduras    543 6.724375e-03
106                                              Hungary    237 2.934948e-03
107                                              Iceland    176 2.179540e-03
108                                                India    582 7.207341e-03
109                                            Indonesia    176 2.179540e-03
110                           Iran (Islamic Republic of)    484 5.993734e-03
111                                                 Iraq    637 7.888447e-03
112                                              Ireland    282 3.492217e-03
113                                               Israel    375 4.643905e-03
114                                                Italy    227 2.811111e-03
115                                              Jamaica    657 8.136122e-03
116                                                Japan    183 2.266226e-03
117                                               Jordan    356 4.408614e-03
118                                           Kazakhstan    138 1.708957e-03
119                                                Kenya    428 5.300244e-03
120                                             Kiribati    215 2.662506e-03
121                                               Kuwait    292 3.616054e-03
122                                           Kyrgyzstan    145 1.795643e-03
123                     Lao People's Democratic Republic    432 5.349779e-03
124                                               Latvia     69 8.544786e-04
125                                              Lebanon    471 5.832745e-03
126                                              Lesotho    437 5.411698e-03
127                                              Liberia    578 7.157806e-03
128                                                Libya    441 5.461233e-03
129                                        Liechtenstein    238 2.947332e-03
130                                            Lithuania     69 8.544786e-04
131                                           Luxembourg     38 4.705824e-04
132                                           Madagascar    492 6.092804e-03
133                                               Malawi    389 4.817278e-03
134                                             Malaysia    358 4.433382e-03
135                                                 Mali    413 5.114488e-03
136                                                Malta    377 4.668673e-03
137                                           Martinique    402 4.978267e-03
138                                           Mauritania    541 6.699607e-03
139                                            Mauritius    597 7.393097e-03
140                                            Melanesia    116 1.436515e-03
141                                               Mexico    304 3.764659e-03
142                                           Micronesia     58 7.182574e-04
143                     Micronesia (Federated States of)    168 2.080470e-03
144                                        Middle Africa    116 1.436515e-03
145                                             Mongolia    194 2.402447e-03
146                                           Montenegro     54 6.687224e-04
147                                           Montserrat    619 7.665540e-03
148                                              Morocco    385 4.767743e-03
149                                           Mozambique    509 6.303328e-03
150                                              Myanmar    341 4.222858e-03
151                                              Namibia    586 7.256876e-03
152                                                Nauru    232 2.873029e-03
153                                                Nepal    329 4.074253e-03
154                                          Netherlands    171 2.117621e-03
155                        Netherlands Antilles (former)    638 7.900831e-03
156                                        New Caledonia    460 5.696524e-03
157                                          New Zealand    191 2.365296e-03
158                                            Nicaragua    600 7.430249e-03
159                                                Niger    387 4.792510e-03
160                                              Nigeria    480 5.944199e-03
161                                                 Niue    420 5.201174e-03
162                                       Norfolk Island      5 6.191874e-05
163                                      North Macedonia    103 1.275526e-03
164                                      Northern Africa    116 1.436515e-03
165                                     Northern America    116 1.436515e-03
166                                      Northern Europe    116 1.436515e-03
167                                               Norway    142 1.758492e-03
168                                              Oceania    116 1.436515e-03
169                                                 Oman    466 5.770826e-03
170                      Pacific Islands Trust Territory    166 2.055702e-03
171                                             Pakistan    298 3.690357e-03
172                                            Palestine    117 1.448898e-03
173                                               Panama    338 4.185707e-03
174                                     Papua New Guinea    515 6.377630e-03
175                                             Paraguay    422 5.225941e-03
176                                                 Peru    312 3.863729e-03
177                                          Philippines    391 4.842045e-03
178                                               Poland    134 1.659422e-03
179                                            Polynesia    116 1.436515e-03
180                                             Portugal    423 5.238325e-03
181                                          Puerto Rico    490 6.068036e-03
182                                                Qatar    316 3.913264e-03
183                                    Republic of Korea    207 2.563436e-03
184                                  Republic of Moldova     85 1.052619e-03
185                                              Réunion    387 4.792510e-03
186                                              Romania    219 2.712041e-03
187                                   Russian Federation     95 1.176456e-03
188                                               Rwanda    352 4.359079e-03
189         Saint Helena, Ascension and Tristan da Cunha    233 2.885413e-03
190                                Saint Kitts and Nevis    338 4.185707e-03
191                                          Saint Lucia    660 8.173273e-03
192                            Saint Pierre and Miquelon    142 1.758492e-03
193                     Saint Vincent and the Grenadines    547 6.773910e-03
194                                                Samoa    465 5.758443e-03
195                                Sao Tome and Principe    640 7.925598e-03
196                                         Saudi Arabia    374 4.631522e-03
197                                              Senegal    289 3.578903e-03
198                                               Serbia     27 3.343612e-04
199                                Serbia and Montenegro     32 3.962799e-04
200                                           Seychelles    457 5.659373e-03
201                                         Sierra Leone    532 6.588154e-03
202                                            Singapore    230 2.848262e-03
203                                             Slovakia     52 6.439549e-04
204                                             Slovenia     66 8.173273e-04
205                                      Solomon Islands    499 6.179490e-03
206                                              Somalia    738 9.139206e-03
207                                   South-eastern Asia    116 1.436515e-03
208                                         South Africa    391 4.842045e-03
209                                        South America    116 1.436515e-03
210                                          South Sudan     42 5.201174e-04
211                                      Southern Africa    116 1.436515e-03
212                                        Southern Asia    116 1.436515e-03
213                                      Southern Europe    116 1.436515e-03
214                                                Spain    176 2.179540e-03
215                                            Sri Lanka    206 2.551052e-03
216                                                Sudan     27 3.343612e-04
217                                       Sudan (former)    411 5.089720e-03
218                                             Suriname    315 3.900880e-03
219                                               Sweden    146 1.808027e-03
220                                          Switzerland    176 2.179540e-03
221                                 Syrian Arab Republic    236 2.922564e-03
222                                           Tajikistan    133 1.647038e-03
223                                             Thailand    410 5.077337e-03
224                                          Timor-Leste    278 3.442682e-03
225                                                 Togo    448 5.547919e-03
226                                              Tokelau    228 2.823494e-03
227                                                Tonga    462 5.721291e-03
228                                  Trinidad and Tobago    690 8.544786e-03
229                                              Tunisia    537 6.650072e-03
230                                               Turkey    170 2.105237e-03
231                                         Turkmenistan    281 3.479833e-03
232                                               Tuvalu    215 2.662506e-03
233                                               Uganda    403 4.990650e-03
234                                              Ukraine    100 1.238375e-03
235                                 United Arab Emirates    399 4.941115e-03
236 United Kingdom of Great Britain and Northern Ireland    150 1.857562e-03
237                          United Republic of Tanzania    447 5.535535e-03
238                             United States of America    290 3.591287e-03
239                         United States Virgin Islands    491 6.080420e-03
240                                              Uruguay    444 5.498384e-03
241                                                 USSR    129 1.597503e-03
242                                           Uzbekistan    107 1.325061e-03
243                                              Vanuatu    529 6.551002e-03
244                   Venezuela (Bolivarian Republic of)    383 4.742975e-03
245                                             Viet Nam    332 4.111404e-03
246                            Wallis and Futuna Islands    557 6.897747e-03
247                                       Western Africa    116 1.436515e-03
248                                         Western Asia    116 1.436515e-03
249                                       Western Europe    116 1.436515e-03
250                                       Western Sahara    183 2.266226e-03
251                                                World    116 1.436515e-03
252                                                Yemen    449 5.560303e-03
253                                         Yugoslav SFR    117 1.448898e-03
254                                               Zambia    533 6.600537e-03
255                                             Zimbabwe    530 6.563386e-03
256                                               Laying   8034 9.949103e-02
257                                         Milk Animals   6296 7.796807e-02
258                                           Production  11555 1.430942e-01
259                                               Stocks  30094 3.726765e-01
260                                                Yield  24772 3.067702e-01
261                                                Asses   4760 5.894664e-02
262                                            Buffaloes    648 8.024668e-03
263                                               Camels   1018 1.260666e-02
264                                               Cattle   3388 4.195614e-02
265                                  Eggs, hen, in shell  27396 3.392651e-01
266                                                Goats   4484 5.552872e-02
267                                               Horses   4838 5.991257e-02
268                                Milk, whole fresh cow  23261 2.880584e-01
269                                                Mules   3277 4.058154e-02
270                                                 Pigs   3995 4.947307e-02
271                                                Sheep   3686 4.564649e-02
272                                            1000 Head   8034 9.949103e-02
273                                             100mg/An  12651 1.566668e-01
274                                                 Head  36390 4.506446e-01
275                                                hg/An  12121 1.501034e-01
276                                               tonnes  11555 1.430942e-01

2.2 Data summary- Numerical

z_score <- function (x) 
    
  { 
    z<- (x-mean(x, na.rm = TRUE))/sd(x, na.rm = TRUE)
    
    tibble(z)
    }
  
numerical<- FAOSATA_data %>%
  select(Value) 

map_dfr(numerical,z_score)
# A tibble: 80,751 × 1
          z
      <dbl>
 1  0.00686
 2 -0.104  
 3 -0.0489 
 4  0.00686
 5 -0.104  
 6 -0.0489 
 7  0.0196 
 8 -0.104  
 9 -0.0409 
10  0.0196 
# ℹ 80,741 more rows
FAOSATA_data %>%
  summarise(across(where(is.numeric),median))
# A tibble: 1 × 2
   Year Value
  <dbl> <dbl>
1  1991 20237