-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGonsalvesAssignment7.Rmd
62 lines (39 loc) · 1.56 KB
/
GonsalvesAssignment7.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
title: "Assignment 7"
author: "MG"
date: "10/10/2020"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(RCurl)
library(XML)
library(jsonlite)
```
## Week 7 Working with XML and JSON in R
Our assignment this week is the choose 3 books (I'm choosing sports books) and include the title, author(s) and two attributes of my choosing. I will then create three separate files in teh HTML, XML, and JSON file formats and post them to my github. Finally, I will write R code and load the three separate files from github and compare the three imported dataframes to see if they are identical.
## Pulling in the HTML code
```{r}
bookhtml <- "https://raw.githubusercontent.com/mjgons/DATA607/master/Data607Books.html"
bookhtml2 <- getURL(bookhtml)
bookhtml3 <- readHTMLTable(bookhtml2, header=TRUE)
bookhtml3
```
## Pulling in the XML code
```{r}
bookxml <- "https://raw.githubusercontent.com/mjgons/DATA607/master/Data607Books.xml"
bookxml2 <- getURL(bookxml)
bookxml3 <- xmlToDataFrame(bookxml2)
bookxml3
```
## Pulling in the JSON code
```{r}
bookjson <- "https://raw.githubusercontent.com/mjgons/DATA607/master/Data607Books2.json"
bookjson2 <- getURL(bookjson)
bookjson3 <- fromJSON(bookjson2)
bookjson3
```
## Conclusion
I created the 3 filetypes: HTML, XML, and JSON by hand as I've never worked with these filetypes before. I then pushed the files to github and then pulled them into R.
The dataframes all look similar. I have a $‘NULL‘ in the html file but other than that, they all look the same.