Exploring Export Data of Pakistan with its partner countries

Why R
There is an increasing recognition of reproducibility of research, though it has limited recognition in social sciences. The document in your hand is written in RMarkdown. RMarkown which can be used for pdf, html, word, PowerPoint/Slidy/Beamer Presentations, Webpages, LaTex and many others. Besides learning basics of R-coding, another objective of this workshop is understanding the importance of reproducibility. Building this new habit of reproducible work at times maybe little challenging occasionally. Getting rid of culture of copying and pasting, and sparing this time for doing data analysis and research is one of the objectives of this or coming workshops. Purpose is to help you to get away from this tedious activity so that you can spend more time doing science.
Uploaded data and required R packages
Understanding data sets requires many hours/days or in some cases weeks.There are many commercially available software but open source community based software have now dominated and R is one of these. R makes data understanding process as easy as possible through the dplyr package. It is one of the easiest solution for code-based data analysis. We will learn in this training how to do it. I have already uploaded videos for downloading packages and relevant information. video links….
I will explore the Export Data and will explain how one can use basic dplyr verbs for data wrangling. Here’s how to load in all required packages:
Exort Data Analysis
Rows: 92,950 Columns: 11 $ Nomenclature TradeValue in 1000 USD
Once data are uploaded, now to get an overview of this data, we display first few rows of data by recalling X_pk data. glimpse command helps to get an overall view of this data. str command will also describe data.
Rows: 92,950
Columns: 11
$ Nomenclature <chr> "H5", "H5", "H5", "H5", "H5", "H5", "H5", "H5…
$ ReporterISO3 <chr> "PAK", "PAK", "PAK", "PAK", "PAK", "PAK", "PA…
$ ProductCode <dbl> 10221, 10221, 10239, 10511, 10511, 10599, 105…
$ ReporterName <chr> "Pakistan", "Pakistan", "Pakistan", "Pakistan…
$ PartnerISO3 <chr> "AFG", "SAU", "AFG", "AFG", "OMN", "AFG", "OM…
$ PartnerName <chr> "Afghanistan", "Saudi Arabia", "Afghanistan",…
$ Year <dbl> 2017, 2017, 2017, 2017, 2017, 2017, 2017, 201…
$ TradeFlowName <chr> "Export", "Export", "Export", "Export", "Expo…
$ TradeFlowCode <dbl> 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, …
$ `TradeValue in 1000 USD` <dbl> 240.335, 0.000, 422.272, 380.257, 0.799, 3416…
$ value_1000_USD <dbl> 240.335, 0.000, 422.272, 380.257, 0.799, 3416…
This indicate that there are 10 variables and 92951 observations. From having an overview of above mentioned variables, we are interested to select few of these variables. For this we use one of the verb select as follows:
| ReporterName | PartnerName | value_1000_USD | ProductCode |
|---|---|---|---|
| Pakistan | Afghanistan | 240.335 | 10221 |
| Pakistan | Saudi Arabia | 0.000 | 10221 |
| Pakistan | Afghanistan | 422.272 | 10239 |
| Pakistan | Afghanistan | 380.257 | 10511 |
| Pakistan | Oman | 0.799 | 10511 |
Or we can drop variables which are not required by using the same select verb but with -ve signs for the variables which we want to drop.
Wait a minute, despite selection of desired variables or droping undesired variables, we have not lost orginal data. This is a very unique feature unlike some softwares where if we drop some variables, we cant re-use those unless we go back and open original file. If we type X_pk we will get same data having 10 variables with 92,951 rows.
Filter and select verb
One may use filter command to keep observations meeting certain criteria and then use select for keeping desired variables.
This table shows data only for 2018 year and have four variables selected.
Ordering by using arranage function
group_by and summarising
Rename variables
