Assignment

Pick three of your favorite books on one of your favorite subjects. At least one of the books should have more than one author. For each book, include the title, authors, and two or three other attributes that you find interesting.
Take the information that you’ve selected about these three books, and separately create three files which store the book’s information in HTML (using an html table), XML, and JSON formats (e.g. “books.html”, “books.xml”, and “books.json”). To help you better understand the different file structures, I’d prefer that you create each of these files “by hand” unless you’re already very comfortable with the file formats.
Write R code, using your packages of choice, to load the information from each of the three sources into separate R data frames. Are the three data frames identical?
Your deliverable is the three source files and the R code. If you can, package your assignment solution up into an .Rmd file and publish to rpubs.com. [This will also require finding a way to make your three text files accessible from the web].

HTML

# load data from html file
books.html <- paste(readLines("books.html"))
books.html <- readHTMLTable(books.html, stringsAsFactors = FALSE)
books.html <- books.html[[1]]
books.html
##                     title                      author       publisher
## 1     capital carceralism                 jackie wang    semiotext(e)
## 2         the information                james gleick  pantheon books
## 3 the communist manifesto karl marx, frederich engels penguin classic
##   year_published pages
## 1           2018   360
## 2           2011   544
## 3           2001    64

XML

# load data from xml file
books.xml <- xmlParse("books.xml")
books.xml <- xmlToDataFrame(books.xml, stringsAsFactors = FALSE)
books.xml
##                     title                      author       publisher
## 1     capital carceralism                 jackie wang    semiotext(e)
## 2         the information                james gleick  pantheon books
## 3 the communist manifesto karl marx, frederich engels penguin classic
##   year_published pages
## 1           2018   360
## 2           2011   544
## 3           2001    64

JSON

# load data from json file
books.json <- fromJSON("books.json")
books.json <- books.json[[1]]
books.json
##                     title                      author       publisher
## 1     capital carceralism                 jackie wang    semiotext(e)
## 2         the information                james gleick  pantheon books
## 3 the communist manifesto karl marx, frederich engels penguin classic
##   year_published pages
## 1           2018   360
## 2           2011   544
## 3           2001    64

Observations

For the most part, the XML, HTML, and JSON-derived dataframes have identical output. The JSON-derived dataframe stands out in having preserved the class that was implied by the lack of double-quotes that wrapped the integer values.