library(DT)
library(XML)
library(jsonlite)tf <- tempfile()
## Download the file
download.file("https://raw.githubusercontent.com/qixing810/CUNYSPS-DataScience/master/DS607/dataset/books.xml", tf)
books_xml <- xmlToDataFrame(tf)
datatable(books_xml)tf1 <- tempfile()
## Download the file
download.file("https://raw.githubusercontent.com/qixing810/CUNYSPS-DataScience/master/DS607/dataset/books.json", tf1)
books_json <- fromJSON(tf1, simplifyDataFrame = TRUE)
# function from [Here](https://stackoverflow.com/questions/48199505/r-read-json-into-a-data-frame)
books_json_table <-
data.table::rbindlist(lapply(books_json, function(x) {
x[] <- lapply(x, function(y) if(is.data.frame(y)) NA else y)
x}))
datatable(books_json_table)tf2 <- tempfile()
## Download the file
download.file("https://raw.githubusercontent.com/qixing810/CUNYSPS-DataScience/master/DS607/dataset/books.html", tf2)
books_html <- readHTMLTable(tf2)
# function from [Here](https://stackoverflow.com/questions/48199505/r-read-json-into-a-data-frame)
books_html_table <-
data.table::rbindlist(lapply(books_html, function(x) {
x[] <- lapply(x, function(y) if(is.data.frame(y)) NA else y)
x}))
datatable(books_html_table)