Introd u ction : Working With Web Data in R W OR K IN G W ITH W - - PowerPoint PPT Presentation

introd u ction working with web data in r
SMART_READER_LITE
LIVE PREVIEW

Introd u ction : Working With Web Data in R W OR K IN G W ITH W - - PowerPoint PPT Presentation

Introd u ction : Working With Web Data in R W OR K IN G W ITH W E B DATA IN R Oli v er Ke y es & Charlo e Wickham Instr u ctors Working w ith Web Data in R Do w nloading les and u sing speciali z ed packages to get data from w eb


slide-1
SLIDE 1

Introduction: Working With Web Data in R

W OR K IN G W ITH W E B DATA IN R

Oliver Keyes & Charloe Wickham

Instructors

slide-2
SLIDE 2

WORKING WITH WEB DATA IN R

Working with Web Data in R

Downloading les and using specialized packages to get data from web

httr package to query APIs using GET() and POST()

JSON and XML: data formats commonly returned CSS to navigate and extract data from webpages

slide-3
SLIDE 3

WORKING WITH WEB DATA IN R

Importing data from a URL

read.csv("http://website.url/remote-file.csv")

slide-4
SLIDE 4

WORKING WITH WEB DATA IN R

Downloading data from a URL

download.file( url = "http://website.url/remote-file.csv", destfile = "local-file.csv" )

slide-5
SLIDE 5

Let's practice!

W OR K IN G W ITH W E B DATA IN R

slide-6
SLIDE 6

Understanding Application Programming Interfaces

W OR K IN G W ITH W E B DATA IN R

Oliver Keyes

Instructor

slide-7
SLIDE 7

WORKING WITH WEB DATA IN R

Application Programming Interfaces

"Websites, but for machines" Can be used to expose data automatically Lets you make queries for specic bits of that data

slide-8
SLIDE 8

WORKING WITH WEB DATA IN R

API Clients

Native (in R!) interfaces to APIs Hides API complexity Lets you read data in as R objects

slide-9
SLIDE 9

WORKING WITH WEB DATA IN R

Using API Clients

Always use a client if you can Find them by googling "CRAN [name of website]" Only write code you have to write

slide-10
SLIDE 10

WORKING WITH WEB DATA IN R

pageviews

library(pageviews) article_pageviews(article = "R_(programming_language)")

slide-11
SLIDE 11

Let's practice!

W OR K IN G W ITH W E B DATA IN R

slide-12
SLIDE 12

Access Tokens and APIs

W OR K IN G W ITH W E B DATA IN R

Charloe Wickham

Instructor

slide-13
SLIDE 13

WORKING WITH WEB DATA IN R

API etiquette

Overwhelming the API means you can't use it Overwhelming the API means nobody else can use it APIs issue "access tokens" to control and identify use

slide-14
SLIDE 14

WORKING WITH WEB DATA IN R

Getting access tokens

Usually requires registering your email address Sometimes providing an explanation Example: hps://www.wordnik.com/ which requires both!

slide-15
SLIDE 15

WORKING WITH WEB DATA IN R

birdnik

birdnik a package that wraps the Wordnik API

Provide API key in key argument in birdnik functions

slide-16
SLIDE 16

Let's practice!

W OR K IN G W ITH W E B DATA IN R