It's Autumn! Prices fall like leaves! - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Reading from a file
9. Loading data from the Internet
Reading from an Excel file
Summary

Instruction

To complete our analysis, we need data about energy prices and gasoline prices in the USA, which will allow us to calculate costs. We can aquire the information from an official page, such as U.S. Government's open data, and manually load it into the memory, or we can simply download the data directly into memory of R. To do this, we use one of our reading functions with the URL as the argument (instead of the filename). Since the gas price data is in CSV format, we'll use the read.csv() function:

read.csv("https://data.ny.gov/api/views/nqur-w4p7/rows.csv")

Note: You can also pass the URL as an argument to both read.delim() and read.table() functions.

Exercise

Using the read.csv() function, download energy price data from the following site:

https://data.ny.gov/api/views/pzgr-wqm5/rows.csv

Assign this data to the energy_price_data variable.