library(knitr)
## Warning: package 'knitr' was built under R version 3.3.3
library(XML)
## Warning: package 'XML' was built under R version 3.3.3
library(jsonlite)
## Warning: package 'jsonlite' was built under R version 3.3.3
library(RCurl)
## Warning: package 'RCurl' was built under R version 3.3.3
## Loading required package: bitops
HTML
doc1 <- "https://cdn.rawgit.com/mdacampora/DATA607-Data-Acquisition-and-Managment/5b06e314/books.html"
books1 <- readHTMLTable(getURL(doc1))
kable(books1)
| Tools of Titans |
Tim Ferriss |
900 |
Health, Wealth, and Widsom |
2017 |
| The Second Law |
P.W. Atkins |
230 |
Physics |
1984 |
| Zero to One: Notes on Startups, or How to Build the Future |
Peter Theil, Blake Masters |
224 |
Business |
2014 |
|
XML
doc2 <- "https://cdn.rawgit.com/mdacampora/DATA607-Data-Acquisition-and-Managment/5b06e314/books.xml"
books2 <- xmlToDataFrame(getURL(doc2))
kable(books2)
| Tools of Titans |
Tim Ferriss |
900 |
Health, Wealth, and Widsom |
2017 |
| The Second Law |
P.W. Atkins |
230 |
Physics |
1984 |
| Zero to One: Notes on Startups, or How to Build the Future |
Peter Theil, Blake Masters |
224 |
Business |
2014 |
| ### JSON |
|
|
|
|
doc3 <- "https://cdn.rawgit.com/mdacampora/DATA607-Data-Acquisition-and-Managment/5b06e314/books.json"
books3 = fromJSON(doc3)
kable(books3)
| Tools of Titans |
Tim Ferriss |
900 |
Health, Wealth, and Widsom |
2017 |
| The Second Law |
P.W. Atkins |
230 |
Physics |
1984 |
| Zero to One: Notes on Startups, or How to Build the Future |
Peter Theil, Blake Masters |
224 |
Business |
2014 |
|
While the dataframes look identical, it appears the data structure for JSON is more like a dictionary and the data may be stored differently.