load packages
library(XML)
library(RCurl)
library(jsonlite)
load data html
htmlurl <- getURL("https://raw.githubusercontent.com/arinolan/Week-8-Assignment/main/books_html")
x <- readHTMLTable(htmlurl)
df_html<-data.frame(x)
colnames(df_html)<-c("title", "author", "year", "price")
df_html
## title author year price
## 1 The Poisonwood Bible Barbara Kingsolver 1998 12.39
## 2 A Fire Sparkling Julianna MacLean 2019 10.99
## 3 My Dear Hamilton Stephanie Dray, Laura Kamoie 2018 12.66
load data xml
xmlurl <- getURL("https://raw.githubusercontent.com/arinolan/Week-8-Assignment/main/books")
y <- xmlParse(xmlurl)
df_xml <- xmlToDataFrame(y)
df_xml
## title author year price
## 1 The Poisonwood Bible Barbara Kingsolver 1998 12.39
## 2 A Fire Sparkling Julianna MacLean 2019 10.99
## 3 My Dear Hamilton Stephanie Dray, Laura Kamoie 2018 12.66
load data json (couldn’t get this to work but here is the code i tried to use..)
jsonurl <- getURL(“https://raw.githubusercontent.com/arinolan/Week-8-Assignment/main/books_json”) df_json <- fromJSON(jsonurl) df_json
after loading and formating the three different files types, we can see that the dataframes are identical.