## Warning: package 'tidyverse' was built under R version 4.4.3
## Warning: package 'ggplot2' was built under R version 4.4.3
## Warning: package 'dplyr' was built under R version 4.4.3
## Warning: package 'openintro' was built under R version 4.4.3
## Warning: package 'xml2' was built under R version 4.4.3
## Warning: package 'jsonlite' was built under R version 4.4.3
##
## Attaching package: 'jsonlite'
## The following object is masked from 'package:purrr':
##
## flatten
##
## Attaching package: 'rvest'
## The following object is masked from 'package:readr':
##
## guess_encoding
# Load HTML file
html_data <- read_html("https://raw.githubusercontent.com/tanzil64/DATA-607-Assignment-07/refs/heads/main/books.html")
table_data <- html_table(html_nodes(html_data, "table")[[1]])
#print("HTML Data:")
#print(table_data)
df_html <-data.frame(table_data)
print(df_html)## Title
## 1 The Politics of Innovation: Why Some Countries Are Better Than Others at Science and Technology
## 2 How the West Came to Rule: The Geopolitical Origins of Capitalism
## 3 The Fourth Industrial Revolution
## Authors
## 1 Mark Zachary Taylor
## 2 Alexander Anievas, Kerem NiÅ\u009fancıoÄ\u009flu
## 3 Klaus Schwab
## Interesting.Attributes
## 1 Explores how politics, rather than institutions, drive S&T competitiveness
## 2 Challenges Eurocentric views by arguing capitalism's rise was a global process
## 3 Discusses technological advancements shaping the future
# Load XML file using xml2
xml_data <- read_xml("https://raw.githubusercontent.com/tanzil64/DATA-607-Assignment-07/refs/heads/main/books.xml")
xml_books <- xml_find_all(xml_data, "//book")
books_list <- lapply(xml_books, function(book) {
list(
title = xml_text(xml_find_first(book, "title")),
authors = xml_text(xml_find_all(book, "authors/author")),
attributes = xml_text(xml_find_all(book, "attributes/attribute"))
)
})
df_xml <-data.frame(books_list)
print(df_xml)## title
## 1 The Politics of Innovation: Why Some Countries Are Better Than Others at Science and Technology
## 2 The Politics of Innovation: Why Some Countries Are Better Than Others at Science and Technology
## authors
## 1 Mark Zachary Taylor
## 2 Mark Zachary Taylor
## attributes
## 1 Explores how politics, rather than institutions, drive S&T competitiveness
## 2 Explores how politics, rather than institutions, drive S&T competitiveness
## title.1
## 1 How the West Came to Rule: The Geopolitical Origins of Capitalism
## 2 How the West Came to Rule: The Geopolitical Origins of Capitalism
## authors.1
## 1 Alexander Anievas
## 2 Kerem Nişancıoğlu
## attributes.1
## 1 Challenges Eurocentric views by arguing capitalism's rise was a global process
## 2 Challenges Eurocentric views by arguing capitalism's rise was a global process
## title.2 authors.2
## 1 The Fourth Industrial Revolution Klaus Schwab
## 2 The Fourth Industrial Revolution Klaus Schwab
## attributes.2
## 1 Discusses technological advancements shaping the future
## 2 Discusses technological advancements shaping the future
# Load JSON file
json_data <- fromJSON("https://raw.githubusercontent.com/tanzil64/DATA-607-Assignment-07/refs/heads/main/books.json")
df_json <-data.frame(json_data)
print(df_json)## books.title
## 1 The Politics of Innovation: Why Some Countries Are Better Than Others at Science and Technology
## 2 How the West Came to Rule: The Geopolitical Origins of Capitalism
## 3 The Fourth Industrial Revolution
## books.authors
## 1 Mark Zachary Taylor
## 2 Alexander Anievas, Kerem Nişancıoğlu
## 3 Klaus Schwab
## books.attributes
## 1 Explores how politics, rather than institutions, drive S&T competitiveness
## 2 Challenges Eurocentric views by arguing capitalism's rise was a global process
## 3 Discusses technological advancements shaping the future
## [1] FALSE
## [1] FALSE
## [1] FALSE
Conclusion: In conclusion we can say that the files are in different format and not identical.