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].
THE THREE DATA FRAMES ARE IDENTICAL; EACH HAS 3 OBSERVATIONS AND 5 VARIABLES. FOR XML, THE ELEMENT WAS REMOVED IN THE DATA FRAME.
# HTML
library(XML)
library(RCurl)
## Loading required package: bitops
url<-getURL("https://raw.githubusercontent.com/vskrelja/607_DataAcqMgt_Skrelja/master/books.html")
tbl_html<-readHTMLTable(url,header = TRUE)
tbl_html <- data.frame(tbl_html[[1]])
tbl_html
## Title Author.1 Author.2 Publish.Date
## 1 OUTLIERS Malcolm Gladwell 11-28-2008
## 2 THINKING, FAST AND SLOW Daniel Kahneman 11-27-2011
## 3 THINK LIKE A FREAK Steven D. Levitt Stephen J. Dubner 07-07-2015
## NYT.Business.Rank
## 1 1
## 2 3
## 3 9
# XML
library(plyr)
## Warning: package 'plyr' was built under R version 3.2.2
library(RCurl)
url<-getURL("https://raw.githubusercontent.com/vskrelja/607_DataAcqMgt_Skrelja/master/books.xml")
tbl_xml<-ldply(xmlToList(url), data.frame)
tbl_xml<-tbl_xml[,-1]
tbl_xml
## Title Author_1 Author_2 Publish_Date
## 1 OUTLIERS Malcolm Gladwell 11-28-2008
## 2 THINKING, FAST AND SLOW Daniel Kahneman 11-27-2011
## 3 THINK LIKE A FREAK Steven D. Levitt Stephen J. Dubner 07-07-2015
## NYT_Business_Rank
## 1 1
## 2 3
## 3 9
# JSON
library(jsonlite)
##
## Attaching package: 'jsonlite'
##
## The following object is masked from 'package:utils':
##
## View
url<-"https://raw.githubusercontent.com/vskrelja/607_DataAcqMgt_Skrelja/master/books.json"
tbl_json <- fromJSON(url, flatten=TRUE)
tbl_json
## Title Author 1 Author 2 Publish Date
## 1 OUTLIERS Malcolm Gladwell 11-28-2008
## 2 THINKING, FAST AND SLOW Daniel Kahneman 11-27-2011
## 3 THINK LIKE A FREAK Steven D. Levitt Stephen J. Dubner 07-07-2015
## NYT Business Rank
## 1 1
## 2 3
## 3 9