Loading Game of Thrones marriages and Creating a Network
Author
Bryn Kruzlic
Published
February 28, 2023
Load in libraries
Code
# load in librariesknitr::opts_chunk$set(echo =TRUE)library(igraph)
Attaching package: 'igraph'
The following objects are masked from 'package:stats':
decompose, spectrum
The following object is masked from 'package:base':
union
Load in data set. This is the Game of Thrones marriages dataset
Code
# read in data setlibrary(readr)got_marriages <-read_csv("_data/got/got_marriages.csv")
Rows: 255 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): From, To, Type, Notes, Generation
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Code
View(got_marriages)
Create a Network
Code
# plot the marriages using igraph#| label: summarymarriages.ig <-graph_from_data_frame(got_marriages, directed =FALSE)plot.igraph(marriages.ig, vertex.size=13)
Is the network directed or undirected? The answer is false.
Is the network weighted or unweighted? The answer is false.
Is the network unimodal or bipartite? The answer is false.
Code
is.bipartite(marriages.ig)
[1] FALSE
Code
is.directed(marriages.ig)
[1] FALSE
Code
is.weighted(marriages.ig)
[1] FALSE
The network is not directed, weighted, or bipartite.
Now, let’s take a look at the vertices and edges of the network.
Code
vcount(marriages.ig)
[1] 20
Code
ecount(marriages.ig)
[1] 255
According to the above code, there is a total of 20 vertices and 255 edges.
---title: "Challenge 1 Kruzlic"author: "Bryn Kruzlic"description: "Loading Game of Thrones marriages and Creating a Network"date: "02/28/2023"format: html: toc: true code-fold: true code-copy: true code-tools: true# editor: visualcategories: - challenge_1 - instructions # - railroads # - faostat # - wildbirds---```{r}#| label: setup#| include: false#| ```### Load in libraries```{r}# load in librariesknitr::opts_chunk$set(echo =TRUE)library(igraph)```### Load in data set. This is the Game of Thrones marriages dataset```{r}# read in data setlibrary(readr)got_marriages <-read_csv("_data/got/got_marriages.csv")View(got_marriages)```### Create a Network```{r}# plot the marriages using igraph#| label: summarymarriages.ig <-graph_from_data_frame(got_marriages, directed =FALSE)plot.igraph(marriages.ig, vertex.size=13)```#### Is the network directed or undirected? The answer is false. #### Is the network weighted or unweighted? The answer is false. #### Is the network unimodal or bipartite? The answer is false. ```{r}is.bipartite(marriages.ig)is.directed(marriages.ig)is.weighted(marriages.ig)```The network is not directed, weighted, or bipartite. ### Now, let's take a look at the vertices and edges of the network.```{r}vcount(marriages.ig)ecount(marriages.ig)```According to the above code, there is a total of 20 vertices and 255 edges. ### Other important factors to consider```{r}table(got_marriages$Type)table(got_marriages$Generation)table(got_marriages$From)```