###Book
This is the books dataframe
library(knitr)
library(tidyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(rvest)
library(xml2)
library(rjson)
library(XML)
books <- data.frame(
title = c("Les Miserable", "The Wind Up Bird Chronicle", "Homegoing", "Punching the Air"),
author = c("Victor Hugo", "Haruki Murakami", "Yaa Gyasi", "Ibi Zoboi, Yusef Salaam"),
year = c("January 1, 1862", "April 12, 1994", "June 7, 2016", "September 1, 2020"),
pages_amount = c(1463, 607, 305, 400)
);
kable(books)
| title | author | year | pages_amount |
|---|---|---|---|
| Les Miserable | Victor Hugo | January 1, 1862 | 1463 |
| The Wind Up Bird Chronicle | Haruki Murakami | April 12, 1994 | 607 |
| Homegoing | Yaa Gyasi | June 7, 2016 | 305 |
| Punching the Air | Ibi Zoboi, Yusef Salaam | September 1, 2020 | 400 |
Reading the html file and loading as a dataframe
library(knitr)
library(tidyr)
library(dplyr)
library(rvest)
library(xml2)
library(rjson)
library(XML)
ddhtml <- read_html("books.html");
ddhtml <- html_table(ddhtml);
kable(ddhtml)
|
Reading the xml file and loading it as a dataframe
library(knitr)
library(tidyr)
library(dplyr)
library(rvest)
library(xml2)
library(rjson)
library(XML)
ddxml <- xmlToDataFrame("books.xml");
kable(ddxml)
| title | author | year | page_amount |
|---|---|---|---|
| Les Miserable | Victor Hugo | January 1, 1862 | 1463 |
| The Wind Up Bird Chronicle | Haruki Murakami | April 12, 1994 | 607 |
| Homegoing | Yaa Gyasi | June 7, 2016 | 305 |
| Punching the Air | Ibi Zoboi, Yusef Salaam | September 1, 2020 | 400 |
Reading the json file and loading it as a dataframe
library(knitr)
library(tidyr)
library(dplyr)
library(rvest)
library(xml2)
library(rjson)
library(XML)
ddjson <- as.data.frame(fromJSON(file = "books.json"));
kable(ddjson)
| book.title | book.author | book.year | book.page_amount | book.title.1 | book.author.1 | book.year.1 | book.page_amount.1 | book.title.2 | book.author.2 | book.year.2 | book.page_amount.2 | book.title.3 | book.author.3 | book.year.3 | book.page_amount.3 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Les Miserable | Victor Hugo | January 1, 1862 | 1463 | The Wind Up Bird Chronicle | Haruki Murakami | April 12, 1994 | 607 | Homegoing | Yaa Gyasi | June 7, 2016 | 305 | Punching the Air | Ibi Zoboi, Yusef Salaam | September 1, 2020 | 400 |
The json format seems to be only one that looks different. Further processing would need to be done to make it look like the others.