Load all packages needed to this assignment

library(XML)
library(jsonlite)
library(htmltools)
library(knitr)
library(htmlTable)
library(RCurl)
## Loading required package: bitops

Read the HTML file into R.

HTMLurl <- "https://raw.githubusercontent.com/ntlrs/data607-homework6/master/html"
HTMLurldata <- getURL(HTMLurl)
HTMLtable <- readHTMLTable(HTMLurldata, header = TRUE)
HTMLtable
## $`NULL`
##                                                                          Title
## 1                                           Game Theory for Applied Economists
## 2 The Art of Strategy: A Game Theorist's Guide to Success in Business and Life
## 3                                       Game Theory: A Very Short Introduction
##                                Author                  Publisher
## 1                      Robert Gibbons Princeton University Press
## 2 Avinash K. Dixit, Barry J. Nalebuff     W. W. Norton & Company
## 3                         Ken Binmore    Oxford University Press
##     Date Published Page Numbers Amazon Rating(Out of 5)
## 1    July 13, 1992    288 pages                     4.1
## 2  January 4, 2010    512 pages                     4.3
## 3 November 2, 2007    200 pages                     2.8
class(HTMLtable)
## [1] "list"
  1. XML
XMLurl <- "https://raw.githubusercontent.com/ntlrs/data607-homework6/master/xml.xml"
XML <-getURL(XMLurl)
XMLurldata <- xmlParse(XML)
XMLtable <- xmlToDataFrame(XMLurldata)
XMLtable
##                                                                          Title
## 1                                           Game Theory for Applied Economists
## 2 The Art of Strategy: A Game Theorist's Guide to Success in Business and Life
## 3                                       Game Theory: A Very Short Introduction
##                               Authors                  Publisher
## 1                      Robert Gibbons Princeton University Press
## 2 Avinash K. Dixit, Barry J. Nalebuff   W. W. Norton and Company
## 3                         Ken Binmore    Oxford University Press
##     Date_Published Page_Numbers Amazon_Rating
## 1    July 13, 1992    288 pages           4.1
## 2  January 4, 2010    512 pages           4.3
## 3 November 2, 2007    200 pages           2.8
####reference: https://stackoverflow.com/questions/23584514/error-xml-content-does-not-seem-to-be-xml-r-3-1-0
####https://www.w3schools.com/xml/default.asp
####https://www.w3schools.com/xml/xml_validator.asp
class(XMLtable)
## [1] "data.frame"
  1. JSON
jsonURL <- "https://raw.githubusercontent.com/ntlrs/data607-homework6/master/json.json"
JSON <- getURL(jsonURL)
JSONurldata <- fromJSON(jsonURL)
JSONurldata
## $books
##                                                                          Title
## 1                                           Game Theory for Applied Economists
## 2 The Art of Strategy: A Game Theorist's Guide to Success in Business and Life
## 3                                       Game Theory: A Very Short Introduction
##                               Authors                  Publisher
## 1                      Robert Gibbons Princeton University Press
## 2 Avinash K. Dixit, Barry J. Nalebuff     W. W. Norton & Company
## 3                         Ken Binmore    Oxford University Press
##     Date_Published Page_Numbers Amazon_Rating
## 1    July 13, 1992    288 pages           4.1
## 2  January 4, 2010    512 pages           4.3
## 3 November 2, 2007    200 pages           2.8
class(JSONurldata)
## [1] "list"
identical(JSONurldata, HTMLtable)
## [1] FALSE
identical(JSONurldata, XMLtable)
## [1] FALSE
identical(XMLtable, HTMLtable)
## [1] FALSE