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 httr package to q u er y APIs u sing GET() and POST() JSON and XML : data formats commonl y ret u rned CSS to na v igate and e x tract data from w ebpages WORKING WITH WEB DATA IN R
Importing data from a URL read.csv("http://website.url/remote-file.csv") WORKING WITH WEB DATA IN R
Do w nloading data from a URL download.file( url = "http://website.url/remote-file.csv", destfile = "local-file.csv" ) WORKING WITH WEB DATA IN R
Let ' s practice ! W OR K IN G W ITH W E B DATA IN R
Understanding Application Programming Interfaces W OR K IN G W ITH W E B DATA IN R Oli v er Ke y es Instr u ctor
Application Programming Interfaces " Websites , b u t for machines " Can be u sed to e x pose data a u tomaticall y Lets y o u make q u eries for speci � c bits of that data WORKING WITH WEB DATA IN R
API Clients Nati v e ( in R !) interfaces to APIs Hides API comple x it y Lets y o u read data in as R objects WORKING WITH WEB DATA IN R
Using API Clients Al w a y s u se a client if y o u can Find them b y googling " CRAN [ name of w ebsite ]" Onl y w rite code y o u ha v e to w rite WORKING WITH WEB DATA IN R
page v ie w s library(pageviews) article_pageviews(article = "R_(programming_language)") WORKING WITH WEB DATA IN R
Let ' s practice ! W OR K IN G W ITH W E B DATA IN R
Access Tokens and APIs W OR K IN G W ITH W E B DATA IN R Charlo � e Wickham Instr u ctor
API etiq u ette O v er w helming the API means y o u can ' t u se it O v er w helming the API means nobod y else can u se it APIs iss u e " access tokens " to control and identif y u se WORKING WITH WEB DATA IN R
Getting access tokens Us u all y req u ires registering y o u r email address Sometimes pro v iding an e x planation E x ample : h � ps ://www.w ordnik . com / w hich req u ires both ! WORKING WITH WEB DATA IN R
birdnik birdnik a package that w raps the Wordnik API Pro v ide API ke y in key arg u ment in birdnik f u nctions WORKING WITH WEB DATA IN R
Let ' s practice ! W OR K IN G W ITH W E B DATA IN R
Recommend
More recommend