Every analysis starts with data; and reading data from different sources into R can be very challenging. Multiple formats, multiple libraries, multiple interfaces, and so on. Fortunately, the authors of
tidyverse created a number of packages to handle reading data in the most common formats in a simple, intuitive way. This exercise set will give you a brief overview of the most important reading functions.
Answers to the exercises are available here.
Please do all exercises using the
tidiverse packages. It will involve the
jsonlite packages. If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.
List all example files available with the
Read the first 10 lines from the
List all sheets in
Read data from the last sheet.
Read the first 3 rows of columns
B from the
system.file("examples", "iris.dta", package = "haven") to find the
iris data-set in Stata format. Read the file.
Read the data about Citibikes at NYC from http://citibikenyc.com/stations/json. How many bikes are available at the moment?
Read the first 5 pages of data from API https://projects.propublica.org/nonprofits/api/v2/search.json?order=revenue.