The goal of this assignment is to give you practice in preparing different datasets for downstream analysis work.
Your task is to:
(1) Choose any three of the “wide” datasets identified in the Week 6 Discussion items. (You may use your own dataset; please don’t use my Sample Post dataset, since that was used in your Week 6 assignment!)
For each of the three chosen datasets:
Create a .CSV file (or optionally, a MySQL database!) that includes all of the information included in the dataset. You’re encouraged to use a “wide” structure similar to how the information appears in the discussion item, so that you can practice tidying and transformations as described below.
Read the information from your .CSV file into R, and use tidyr and dplyr as needed to tidy and transform your data. [Most of your grade will be based on this step!]
Perform the analysis requested in the discussion item.
Your code should be in an R Markdown file, posted to rpubs.com, and should include narrative descriptions of your data cleanup work, analysis, and conclusions.
Wide Data Set # 1
Choose a wide data set from the Week 5/6 discussions to convert into long data set and generate analysis from the long data set. Screenshot of discussion data set below. I chose this dataset because it was a wide dataset.

CSV file has been loaded to github
There are over 80 variable country columns. 10 of the variable country name columns will be chosen to be renamed as a abbreviated country name along with the year. NA values will be removed. And then the abbreviated variable country names except the year column will be turned into rows. This will turn the wide data set to a long data set.
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(tidyr)
df2_wide<-rename(df_wide,Year=X,ARG=Argentina,SWE=Sweden,US=United.States,KOR=Korea..Rep.,JPN=Japan,BRA=Brazil,CAN=Canada,IND=India,MEX=Mexico,IRE=Ireland)
df3_wide<-select(df2_wide,Year,ARG,SWE,US,KOR,JPN,BRA,CAN,IND,MEX,IRE)
df4_wide<-na.omit(df3_wide)
head(df4_wide)
## Year ARG SWE US KOR JPN BRA CAN
## 25 2013 7.076472 8.004120 7.358333 3.108333 4.021680 7.191545 7.100000
## 26 2014 7.270868 7.931666 6.158333 3.500000 3.587407 6.784583 6.925000
## 27 2015 6.611389 7.378905 5.275000 3.600000 3.371420 8.304733 6.900000
## 28 2016 8.467953 6.940763 4.875000 3.675000 3.112862 11.281130 6.991667
## 29 2017 8.344703 6.674000 4.350000 3.683333 2.806622 12.764030 6.333333
## IND MEX IRE
## 25 8.2 4.903333 13.775000
## 26 9.3 4.824167 11.900000
## 27 8.5 4.347500 9.950000
## 28 8.0 3.882500 8.391667
## 29 8.8 3.420833 6.733333
df_long<-gather(df4_wide,Country,UnemploymentRate,-Year)
head(df_long)
## Year Country UnemploymentRate
## 1 2013 ARG 7.076472
## 2 2014 ARG 7.270868
## 3 2015 ARG 6.611389
## 4 2016 ARG 8.467953
## 5 2017 ARG 8.344703
## 6 2013 SWE 8.004120