pacman::p_load(jsonlite, tidygraph,
ggraph, tidyverse, readtext,
quanteda, tidytext)In-class Exercise 5b
5.3 Loading the necessary R packages
In the code chunk below, fromJSON() of jsonlite package is used to import MC3.json into R environment.
mc1_data <- fromJSON("data/MC1/mc1.json")mc2_data <- fromJSON("data/MC2/mc2.json")
Note
When attempting to read MC3 data an error message shows up, indicating that there is a problem with the JSON data itself. More specifically an invalid character or format issue at the specified location. This issue is being addressed in Take-home exercise 3.

5.4 Creating separate tibbles for nodes and edges
mc2 <- fromJSON("data/MC2/Oceanus Information/Oceanus Geography Nodes.json")If other packages used they might be in individual form. From “links” we can observe the time series changes.
mc2_nodes <- as_tibble(mc2_data$nodes) %>%
# Select can be used to reorder dataframe columns
select(id, type, name)
mc2_edges <- as_tibble(mc2_data$links) %>%
# Move Source and Target to the front
select(source, target, type, key)