HTTP

Intermediate Importing Data in R

Filip Schouwenaars

Instructor, DataCamp

Data on the web

  • Already worked with it!

  • Many packages handle it for you

  • File formats useful for web technology

  • JSON

Intermediate Importing Data in R

HTTP

  • HyperText Transfer Protocol

  • Rules about data exchange between computers

  • Language of the web

ch_3_1_slide.011.png

Intermediate Importing Data in R

HTTP

  • HyperText Transfer Protocol

  • Rules about data exchange between computers

  • Language of the web

ch_3_1_slide.012.png

Intermediate Importing Data in R

HTTP

  • HyperText Transfer Protocol

  • Rules about data exchange between computers

  • Language of the web

ch_3_1_slide.013.png

Intermediate Importing Data in R

HTTP

  • HyperText Transfer Protocol

  • Rules about data exchange between computers

  • Language of the web

ch_3_1_slide.014.png

Intermediate Importing Data in R

HTTP

  • HyperText Transfer Protocol

  • Rules about data exchange between computers

  • Language of the web

ch_3_1_slide.015.png

Intermediate Importing Data in R

Example: CSV

http://assets.datacamp.com/ ... /states.csv

# Manually download file through web browser

read.csv(url("path/to/states.csv"))
         state    capital pop_mill area_sqm
1 South Dakota     Pierre    0.853    77116
2     New York     Albany   19.746    54555
3       Oregon      Salem    3.970    98381
4      Vermont Montpelier    0.627     9616
5       Hawaii   Honolulu    1.420    10931
Intermediate Importing Data in R

Example: CSV

read.csv("http://assets.datacamp.com/course/
                 importing_data_into_r/states.csv")
         state    capital pop_mill area_sqm
1 South Dakota     Pierre    0.853    77116
2     New York     Albany   19.746    54555
3       Oregon      Salem    3.970    98381
4      Vermont Montpelier    0.627     9616
5       Hawaii   Honolulu    1.420    10931
  • R sees it’s a URL, does GET request, and reads in the CSV file
Intermediate Importing Data in R

Example: CSV

read.csv("http://assets.datacamp.com/course/
                 importing_data_into_r/states.csv")
         state    capital pop_mill area_sqm
1 South Dakota     Pierre    0.853    77116
2     New York     Albany   19.746    54555
3       Oregon      Salem    3.970    98381
4      Vermont Montpelier    0.627     9616
5       Hawaii   Honolulu    1.420    10931
  • HTTPS support since R version 3.2.2
Intermediate Importing Data in R

Let's practice!

Intermediate Importing Data in R

Preparing Video For Download...