Skip to main content Accessibility help
×
Hostname: page-component-7bb8b95d7b-2h6rp Total loading time: 0 Render date: 2024-10-06T20:33:55.315Z Has data issue: false hasContentIssue false

4 - Collecting Data

from PART TWO - COLLECTING AND CLEANING DATA

Published online by Cambridge University Press:  15 September 2017

Jose Manuel Magallanes Reyes
Affiliation:
University of Washington and Pontificia Universidad Católica del Perú
Get access

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 Research
Collecting and Organizing Data with R and Python
, pp. 85 - 125
Publisher: Cambridge University Press
Print publication year: 2017

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure [email protected] is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×