4 - Collecting Data
from PART TWO - COLLECTING AND CLEANING DATA
Published online by Cambridge University Press: 15 September 2017
Summary
This section describes how to use R and Python to help you with the second step of the roadmap in Section 1.1 on page 4. You are taking this step because you need to get some data. However, this step assumes that you already have defined a problem you want to understand better, have laid out some hypotheses, and have identified relevant data sources, as discussed in Section 1.1; those tasks drew more on your critical thinking skills than your computational skills.
So, now you are in a situation where you know what data to collect and from where. The source can be a webpage or a file to be downloaded. Most of the time you will get files, so make sure you understand exactly what each variable means and how the values are represented in the file. This requires that you read the documentation of the data file, paying particular attention to the methodology used to collect the data.
Knowing Where Your Files Are
None of the examples in the previous chapters imported a data file, but for the rest of the book, we will only work with real data files. I recommend that from now on, you keep all your files in Dropbox, as I suggested in Section 2.3 on page 22. The data for this book is in a folder named BookData, and you can use this shortened link to download it: https://goo.gl/Czi3Vh. The screen will look similar to Figure 4.1.
If you have installed Dropbox in your machine, you only need to select the option Save to my Dropbox, which will appear after you press the Download button in the right upper corner, as also shown in Figure 4.1. I strongly recommend placing the “BookData” folder in the Dropbox root folder (I assume you have done so in my examples). If you do not want Dropbox, just go for the option Download as .zip and then unzip the folder in the root of your computer.
Next, tell RStudio that you want to be in the “chapter4” folder and that you also want all your code to be saved there.
- Type
- Chapter
- Information
- Introduction to Data Science for Social and Policy ResearchCollecting and Organizing Data with R and Python, pp. 85 - 125Publisher: Cambridge University PressPrint publication year: 2017