Working with web data

R can directly access data stored as .csv files (and/or other formats) from the web. It is as simple as passing the URL to the fread function.

For example, the following loads data directly from the web into flights_extra:

flights_extra <- fread("http://ourairports.com/data/airports.csv")

There are also dedicated packages to work with web pages. One such example is httr as shown as follows:

install.packages("httr") 

library(httr)

rxds <- GET("http://www.rxdatascience.com")

rxds

# View the HTTP headers
headers(rxds)

# View the content
content_rxds <- content(rxds, "text")

substr(content_rxds,1,500)

# Use parsers
str(content(rxds, "parsed"))
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.199.184