On Rpubs at: https://rpubs.com/jefedigital/853859
HTML
html_url <- 'https://raw.githubusercontent.com/jefedigital/cuny-data-607/main/classes/week%207%20-%20web%20technologies/assignment/data/mybooks.html'
html_df <- read_html(html_url) %>%
html_elements(xpath='//table') %>%
html_table(header=TRUE) %>%
as.data.frame()
| The Functional Art |
An introduction to information graphics and visualization |
Cairo, Alberto |
New Riders |
2013 |
978-0-321-83473-7 |
4.4 |
Information visualization, Computer graphics, Optical images, Charts, diagrams, etc |
| How to Measure Anything, 3rd Edition |
Finding the value of intangibles in business |
Hubbard, Douglas W. |
Wiley |
2014 |
978-1-118-53927-9 |
4.5 |
Intangible property - Valuation |
| R for Data Science |
Import, Tidy, Transform, Visualize and Model Data |
Wickham, Hadley; Grolemund, Garrett |
O’Reilly |
2017 |
978-1-491-91039-9 |
4.7 |
R, Big data, Databases, Electronic data processing, Statistics - Data processing, Data mining, Information vizualization |
XML
xml_url <- 'https://raw.githubusercontent.com/jefedigital/cuny-data-607/main/classes/week%207%20-%20web%20technologies/assignment/data/mybooks.xml'
xml_df <- read_xml(xml_url) %>%
xml_find_all('/mybooks/book') %>%
map(xml_children) %>%
map_df(~map(setNames(xml_text(.), xml_name(.)), type.convert, as.is=TRUE))
| The Functional Art |
An introduction to information graphics and visualization |
Cairo, Alberto |
New Riders |
2013 |
978-0-321-83473-7 |
4.4 |
Information visualization, Computer graphics, Optical images, Charts, diagrams, etc |
| How to Measure Anything, 3rd Edition |
Finding the value of intangibles in business |
Hubbard, Douglas W. |
Wiley |
2014 |
978-1-118-53927-9 |
4.5 |
Intangible property - Valuation |
| R for Data Science |
Import, Tidy, Transform, Visualize and Model Data |
Wickham, Hadley; Grolemund, Garrett |
O’Reilly |
2017 |
978-1-491-91039-9 |
4.7 |
R, Big data, Databases, Electronic data processing, Statistics - Data processing, Data mining, Information vizualization |
JSON
json_url <- 'https://raw.githubusercontent.com/jefedigital/cuny-data-607/main/classes/week%207%20-%20web%20technologies/assignment/data/mybooks.json'
json_df <- read_html(json_url) %>%
html_elements(xpath='//body/p') %>%
html_text() %>%
str_replace_all("[\r\n]", "") %>%
str_replace_all(" +", " ") %>%
enter_object(mybooks) %>%
gather_array %>%
spread_all %>%
as_data_frame.tbl_json() %>%
select(!c(document.id, array.index))
| The Functional Art |
An introduction to information graphics and visualization |
Cairo, Alberto |
New Riders |
2013 |
978-0-321-83473-7 |
4.4 |
Information visualization, Computer graphics, Optical images, Charts, diagrams, etc |
| How to Measure Anything, 3rd Edition |
Finding the value of intangibles in business |
Hubbard, Douglas W. |
Wiley |
2014 |
978-1-118-53927-9 |
4.5 |
Intangible property - Valuation |
| R for Data Science |
Import, Tidy, Transform, Visualize and Model Data |
Wickham, Hadley; Grolemund, Garrett |
O’Reilly |
2017 |
978-1-491-91039-9 |
4.7 |
R, Big data, Databases, Electronic data processing, Statistics - Data processing, Data mining, Information vizualization |