DACSS 601: Data Science Fundamentals - FALL 2022
  • Fall 2022 Posts
  • Contributors
  • DACSS

Challenge 1

  • Course information
    • Overview
    • Instructional Team
    • Course Schedule
  • Weekly materials
    • Fall 2022 posts
    • final posts

On this page

  • Challenge Overview
  • Read in the Data
  • Describe the data

Challenge 1

  • Show All Code
  • Hide All Code

  • View Source
challenge_1
railroads
faostat
wildbirds
Author

Tracy Tien

Published

Invalid Date

Code
library(tidyverse)

knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)

Challenge Overview

Today’s challenge is to

  1. read in a dataset, and

  2. describe the dataset using both words and any supporting information (e.g., tables, etc)

Read in the Data

Read in one (or more) of the following data sets, using the correct R package and command.

  • railroad_2012_clean_county.csv ⭐
  • birds.csv ⭐⭐
  • FAOstat*.csv ⭐⭐
  • wild_bird_data.xlsx ⭐⭐⭐
  • StateCounty2012.xls ⭐⭐⭐⭐

Find the _data folder, located inside the posts folder. Then you can read in the data, using either one of the readr standard tidy read commands, or a specialized package such as readxl.

Code
birds <- read_csv("_data/birds.csv")
spec(birds)
cols(
  `Domain Code` = col_character(),
  Domain = col_character(),
  `Area Code` = col_double(),
  Area = col_character(),
  `Element Code` = col_double(),
  Element = col_character(),
  `Item Code` = col_double(),
  Item = col_character(),
  `Year Code` = col_double(),
  Year = col_double(),
  Unit = col_character(),
  Value = col_double(),
  Flag = col_character(),
  `Flag Description` = col_character()
)
Code
# birds.csv has 14 columns, and the results of the column specifications indicates that the first line of the .csv contains column names.
dim(birds)
[1] 30977    14
Code
# birds.csv has 30977 rows and 14 columns
head(birds)
# A tibble: 6 × 14
  Domai…¹ Domain Area …² Area  Eleme…³ Element Item …⁴ Item  Year …⁵  Year Unit 
  <chr>   <chr>    <dbl> <chr>   <dbl> <chr>     <dbl> <chr>   <dbl> <dbl> <chr>
1 QA      Live …       2 Afgh…    5112 Stocks     1057 Chic…    1961  1961 1000…
2 QA      Live …       2 Afgh…    5112 Stocks     1057 Chic…    1962  1962 1000…
3 QA      Live …       2 Afgh…    5112 Stocks     1057 Chic…    1963  1963 1000…
4 QA      Live …       2 Afgh…    5112 Stocks     1057 Chic…    1964  1964 1000…
5 QA      Live …       2 Afgh…    5112 Stocks     1057 Chic…    1965  1965 1000…
6 QA      Live …       2 Afgh…    5112 Stocks     1057 Chic…    1966  1966 1000…
# … with 3 more variables: Value <dbl>, Flag <chr>, `Flag Description` <chr>,
#   and abbreviated variable names ¹​`Domain Code`, ²​`Area Code`,
#   ³​`Element Code`, ⁴​`Item Code`, ⁵​`Year Code`
Code
colnames(birds)
 [1] "Domain Code"      "Domain"           "Area Code"        "Area"            
 [5] "Element Code"     "Element"          "Item Code"        "Item"            
 [9] "Year Code"        "Year"             "Unit"             "Value"           
[13] "Flag"             "Flag Description"

Add any comments or documentation as needed. More challenging data sets may require additional code chunks and documentation.

Describe the data

Using a combination of words and results of R commands, can you provide a high level description of the data? Describe as efficiently as possible where/how the data was (likely) gathered, indicate the cases and variables (both the interpretation and any details you deem useful to the reader to fully understand your chosen data).

Code
# Some of the columns are intuitive (i.e. Area = country, Unit = quantity) but others can be explored further.
table(select(birds, "Domain Code")) 
Domain Code
   QA 
30977 
Code
table(select(birds, "Domain"))
Domain
Live Animals 
       30977 
Code
# There's only 1 "Domain" type: Live Animals, and the code is: QA
table(select(birds, "Area"))
Area
                                         Afghanistan 
                                                  58 
                                              Africa 
                                                 290 
                                             Albania 
                                                 232 
                                             Algeria 
                                                 232 
                                      American Samoa 
                                                  58 
                                            Americas 
                                                 232 
                                              Angola 
                                                  58 
                                 Antigua and Barbuda 
                                                  58 
                                           Argentina 
                                                 232 
                                             Armenia 
                                                  54 
                                               Aruba 
                                                  29 
                                                Asia 
                                                 290 
                                           Australia 
                                                 174 
                           Australia and New Zealand 
                                                 232 
                                             Austria 
                                                 232 
                                          Azerbaijan 
                                                  54 
                                             Bahamas 
                                                  58 
                                             Bahrain 
                                                  58 
                                          Bangladesh 
                                                 116 
                                            Barbados 
                                                 116 
                                             Belarus 
                                                  81 
                                             Belgium 
                                                  76 
                                  Belgium-Luxembourg 
                                                 156 
                                              Belize 
                                                 174 
                                               Benin 
                                                  58 
                                             Bermuda 
                                                 110 
                                              Bhutan 
                                                  58 
                    Bolivia (Plurinational State of) 
                                                 174 
                              Bosnia and Herzegovina 
                                                 108 
                                            Botswana 
                                                  58 
                                              Brazil 
                                                 174 
                                   Brunei Darussalam 
                                                 116 
                                            Bulgaria 
                                                 232 
                                        Burkina Faso 
                                                  58 
                                             Burundi 
                                                  86 
                                          Cabo Verde 
                                                  58 
                                            Cambodia 
                                                 116 
                                            Cameroon 
                                                  58 
                                              Canada 
                                                 232 
                                           Caribbean 
                                                 232 
                                      Cayman Islands 
                                                  53 
                            Central African Republic 
                                                 116 
                                     Central America 
                                                 174 
                                        Central Asia 
                                                 108 
                                                Chad 
                                                  58 
                                               Chile 
                                                 116 
                                China, Hong Kong SAR 
                                                 279 
                                    China, Macao SAR 
                                                  58 
                                     China, mainland 
                                                 174 
                           China, Taiwan Province of 
                                                 232 
                                            Colombia 
                                                  58 
                                             Comoros 
                                                  58 
                                               Congo 
                                                  58 
                                        Cook Islands 
                                                 109 
                                          Costa Rica 
                                                  58 
                                       Côte d'Ivoire 
                                                  86 
                                             Croatia 
                                                 108 
                                                Cuba 
                                                  58 
                                              Cyprus 
                                                 277 
                                             Czechia 
                                                 104 
                                      Czechoslovakia 
                                                 128 
               Democratic People's Republic of Korea 
                                                 116 
                    Democratic Republic of the Congo 
                                                  58 
                                             Denmark 
                                                 232 
                                            Dominica 
                                                  58 
                                  Dominican Republic 
                                                  58 
                                      Eastern Africa 
                                                 232 
                                        Eastern Asia 
                                                 290 
                                      Eastern Europe 
                                                 232 
                                             Ecuador 
                                                 232 
                                               Egypt 
                                                 290 
                                         El Salvador 
                                                  58 
                                   Equatorial Guinea 
                                                 116 
                                             Eritrea 
                                                  26 
                                             Estonia 
                                                 108 
                                            Eswatini 
                                                  58 
                                            Ethiopia 
                                                  26 
                                        Ethiopia PDR 
                                                  32 
                                              Europe 
                                                 290 
                         Falkland Islands (Malvinas) 
                                                  58 
                                                Fiji 
                                                 174 
                                             Finland 
                                                 166 
                                              France 
                                                 290 
                                       French Guyana 
                                                 116 
                                    French Polynesia 
                                                 116 
                                               Gabon 
                                                  58 
                                              Gambia 
                                                  58 
                                             Georgia 
                                                  54 
                                             Germany 
                                                 232 
                                               Ghana 
                                                  58 
                                              Greece 
                                                 290 
                                             Grenada 
                                                  58 
                                          Guadeloupe 
                                                 154 
                                                Guam 
                                                  58 
                                           Guatemala 
                                                  58 
                                              Guinea 
                                                  58 
                                       Guinea-Bissau 
                                                  58 
                                              Guyana 
                                                  58 
                                               Haiti 
                                                 232 
                                            Honduras 
                                                  58 
                                             Hungary 
                                                 232 
                                             Iceland 
                                                  58 
                                               India 
                                                 116 
                                           Indonesia 
                                                 116 
                          Iran (Islamic Republic of) 
                                                 232 
                                                Iraq 
                                                  58 
                                             Ireland 
                                                 232 
                                              Israel 
                                                 212 
                                               Italy 
                                                 116 
                                             Jamaica 
                                                  58 
                                               Japan 
                                                 116 
                                              Jordan 
                                                 248 
                                          Kazakhstan 
                                                  54 
                                               Kenya 
                                                  58 
                                            Kiribati 
                                                  58 
                                              Kuwait 
                                                  58 
                                          Kyrgyzstan 
                                                 108 
                    Lao People's Democratic Republic 
                                                 174 
                                              Latvia 
                                                  54 
                                             Lebanon 
                                                  92 
                                             Lesotho 
                                                  58 
                                             Liberia 
                                                 116 
                                               Libya 
                                                  58 
                                       Liechtenstein 
                                                  58 
                                           Lithuania 
                                                 108 
                                          Luxembourg 
                                                  19 
                                          Madagascar 
                                                 232 
                                              Malawi 
                                                  58 
                                            Malaysia 
                                                 116 
                                                Mali 
                                                  58 
                                               Malta 
                                                 164 
                                          Martinique 
                                                 160 
                                          Mauritania 
                                                  58 
                                           Mauritius 
                                                 232 
                                           Melanesia 
                                                 174 
                                              Mexico 
                                                 174 
                                          Micronesia 
                                                 116 
                    Micronesia (Federated States of) 
                                                  56 
                                       Middle Africa 
                                                 174 
                                            Mongolia 
                                                  58 
                                          Montenegro 
                                                  13 
                                          Montserrat 
                                                  58 
                                             Morocco 
                                                 116 
                                          Mozambique 
                                                 232 
                                             Myanmar 
                                                 290 
                                             Namibia 
                                                 116 
                                               Nauru 
                                                  58 
                                               Nepal 
                                                 116 
                                         Netherlands 
                                                 166 
                       Netherlands Antilles (former) 
                                                  58 
                                       New Caledonia 
                                                  58 
                                         New Zealand 
                                                 232 
                                           Nicaragua 
                                                  58 
                                               Niger 
                                                  58 
                                             Nigeria 
                                                  58 
                                                Niue 
                                                  58 
                                     North Macedonia 
                                                  27 
                                     Northern Africa 
                                                 290 
                                    Northern America 
                                                 232 
                                     Northern Europe 
                                                 232 
                                              Norway 
                                                 174 
                                             Oceania 
                                                 232 
                                                Oman 
                                                  86 
                     Pacific Islands Trust Territory 
                                                  60 
                                            Pakistan 
                                                 116 
                                           Palestine 
                                                  58 
                                              Panama 
                                                 174 
                                    Papua New Guinea 
                                                 174 
                                            Paraguay 
                                                 232 
                                                Peru 
                                                  58 
                                         Philippines 
                                                 232 
                                              Poland 
                                                 232 
                                           Polynesia 
                                                 116 
                                            Portugal 
                                                 131 
                                         Puerto Rico 
                                                  58 
                                               Qatar 
                                                  58 
                                   Republic of Korea 
                                                 228 
                                 Republic of Moldova 
                                                  54 
                                             Réunion 
                                                 157 
                                             Romania 
                                                 232 
                                  Russian Federation 
                                                 108 
                                              Rwanda 
                                                 128 
        Saint Helena, Ascension and Tristan da Cunha 
                                                  58 
                               Saint Kitts and Nevis 
                                                  58 
                                         Saint Lucia 
                                                  58 
                           Saint Pierre and Miquelon 
                                                  92 
                    Saint Vincent and the Grenadines 
                                                  58 
                                               Samoa 
                                                  58 
                               Sao Tome and Principe 
                                                 174 
                                        Saudi Arabia 
                                                  89 
                                             Senegal 
                                                  58 
                                              Serbia 
                                                  52 
                               Serbia and Montenegro 
                                                  56 
                                          Seychelles 
                                                 116 
                                        Sierra Leone 
                                                 116 
                                           Singapore 
                                                 116 
                                            Slovakia 
                                                 104 
                                            Slovenia 
                                                 108 
                                     Solomon Islands 
                                                  58 
                                             Somalia 
                                                  58 
                                  South-eastern Asia 
                                                 290 
                                        South Africa 
                                                 232 
                                       South America 
                                                 232 
                                         South Sudan 
                                                   7 
                                     Southern Africa 
                                                 290 
                                       Southern Asia 
                                                 232 
                                     Southern Europe 
                                                 290 
                                               Spain 
                                                 176 
                                           Sri Lanka 
                                                 116 
                                               Sudan 
                                                   7 
                                      Sudan (former) 
                                                  51 
                                            Suriname 
                                                 116 
                                              Sweden 
                                                 116 
                                         Switzerland 
                                                 232 
                                Syrian Arab Republic 
                                                 290 
                                          Tajikistan 
                                                  27 
                                            Thailand 
                                                 174 
                                         Timor-Leste 
                                                  58 
                                                Togo 
                                                  58 
                                             Tokelau 
                                                  58 
                                               Tonga 
                                                  58 
                                 Trinidad and Tobago 
                                                  58 
                                             Tunisia 
                                                  93 
                                              Turkey 
                                                 232 
                                        Turkmenistan 
                                                  54 
                                              Tuvalu 
                                                  58 
                                              Uganda 
                                                  58 
                                             Ukraine 
                                                 108 
                                United Arab Emirates 
                                                  58 
United Kingdom of Great Britain and Northern Ireland 
                                                 232 
                         United Republic of Tanzania 
                                                 116 
                            United States of America 
                                                 174 
                        United States Virgin Islands 
                                                  58 
                                             Uruguay 
                                                 232 
                                                USSR 
                                                  62 
                                          Uzbekistan 
                                                  54 
                                             Vanuatu 
                                                  58 
                  Venezuela (Bolivarian Republic of) 
                                                  58 
                                            Viet Nam 
                                                 116 
                           Wallis and Futuna Islands 
                                                  58 
                                      Western Africa 
                                                 116 
                                        Western Asia 
                                                 290 
                                      Western Europe 
                                                 290 
                                               World 
                                                 290 
                                               Yemen 
                                                  58 
                                        Yugoslav SFR 
                                                 124 
                                              Zambia 
                                                  58 
                                            Zimbabwe 
                                                 174 
Code
n_distinct(select(birds, "Area"))
[1] 248
Code
# Based on the "Area" and "Flag Description," which there are 248 UN Food and Agriculture recognized countries 
table(select(birds, "Item"))
Item
              Chickens                  Ducks Geese and guinea fowls 
                 13074                   6909                   4136 
  Pigeons, other birds                Turkeys 
                  1165                   5693 
Code
# The types of birds under items are: chickens, Ducks Geese and guinea fowls, pigeons/other birds, turkeys
table(select(birds, "Year"))
Year
1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 
 493  493  493  493  494  495  495  495  498  498  498  498  498  499  499  499 
1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 
 498  498  497  496  498  498  495  498  499  499  500  502  503  512  514  569 
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 
 574  574  574  574  574  574  574  575  575  575  575  575  575  576  576  576 
2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 
 576  576  576  577  577  577  577  577  577  577 
Code
# The records span from 1961 to 2018.
# To summarize, there are 248 countries (under UN FAO), from 1961-2018, where "Value" indicates each year's total value for each type of livestock bird (chicken, ducks geese and guinea fowls, pigeons and other birds, turkeys)
Source Code
---
title: "Challenge 1"
author: "Tracy Tien"
desription: "Reading in data and creating a post"
date: "What is time these days?"
format:
  html:
    toc: true
    code-fold: true
    code-copy: true
    code-tools: true
categories:
  - challenge_1
  - railroads
  - faostat
  - wildbirds
---

```{r}
#| label: setup
#| warning: false
#| message: false

library(tidyverse)

knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)
```

## Challenge Overview

Today's challenge is to

1)  read in a dataset, and

2)  describe the dataset using both words and any supporting information (e.g., tables, etc)

## Read in the Data

Read in one (or more) of the following data sets, using the correct R package and command.

-   railroad_2012_clean_county.csv ⭐
-   birds.csv ⭐⭐
-   FAOstat\*.csv ⭐⭐
-   wild_bird_data.xlsx ⭐⭐⭐
-   StateCounty2012.xls ⭐⭐⭐⭐

Find the `_data` folder, located inside the `posts` folder. Then you can read in the data, using either one of the `readr` standard tidy read commands, or a specialized package such as `readxl`.

```{r}
birds <- read_csv("_data/birds.csv")
spec(birds)
# birds.csv has 14 columns, and the results of the column specifications indicates that the first line of the .csv contains column names.
dim(birds)
# birds.csv has 30977 rows and 14 columns
head(birds)
colnames(birds)
```


Add any comments or documentation as needed. More challenging data sets may require additional code chunks and documentation.

## Describe the data

Using a combination of words and results of R commands, can you provide a high level description of the data? Describe as efficiently as possible where/how the data was (likely) gathered, indicate the cases and variables (both the interpretation and any details you deem useful to the reader to fully understand your chosen data).

```{r}
# Some of the columns are intuitive (i.e. Area = country, Unit = quantity) but others can be explored further.
table(select(birds, "Domain Code")) 
table(select(birds, "Domain"))
# There's only 1 "Domain" type: Live Animals, and the code is: QA
table(select(birds, "Area"))
n_distinct(select(birds, "Area"))
# Based on the "Area" and "Flag Description," which there are 248 UN Food and Agriculture recognized countries 
table(select(birds, "Item"))
# The types of birds under items are: chickens, Ducks Geese and guinea fowls, pigeons/other birds, turkeys
table(select(birds, "Year"))
# The records span from 1961 to 2018.
# To summarize, there are 248 countries (under UN FAO), from 1961-2018, where "Value" indicates each year's total value for each type of livestock bird (chicken, ducks geese and guinea fowls, pigeons and other birds, turkeys)
```