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
got_marriages
# A tibble: 255 × 5
From To Type Notes Generation
<chr> <chr> <chr> <chr> <chr>
1 Targaryen Stark Married R+L=J Current
2 Baratheon Martell Engaged died Current
3 Baratheon Stark Engaged broken Current
4 Martell Essos Married <NA> Current
5 Martell Reach Affair <NA> Current
6 Martell Essos Affair <NA> Current
7 Martell Essos Affair <NA> Current
8 Martell Septa Affair <NA> Current
9 Martell Dorne Affair <NA> Current
10 Martell Targaryen Married <NA> Current
# … with 245 more rows
Create a Network
Creating an igraph object and finding out whether the network directed, weighted or bipartite.
Code
# not adjacency matrix, not n x n matrix => undirectedgot_marriages.ig <-graph_from_data_frame(got_marriages, directed =FALSE)head(got_marriages.ig)
# describing the networkis_directed(got_marriages.ig)
[1] FALSE
Code
is_bipartite(got_marriages.ig)
[1] FALSE
Code
is_weighted(got_marriages.ig)
[1] FALSE
Thus, this network is undirected, unimodal, and unweighted.
Now, I’ll plot the network:
Code
# plotting the network plot(got_marriages.ig, edge.curved=.1, vertex.color ="orange")
Source Code
---title: "Week 1 Challenge"author: "Ananya Pujary"description: "Loading Data and Creating a Network"date: "02/22/2023"format: html: toc: true code-fold: true code-copy: true code-tools: true# editor: visualcategories: - challenge_1 - Ananya Pujary # - railroads # - faostat # - wildbirds---```{r}#| label: setup #| include: falselibrary(tidyverse) library(igraph)library(GGally)library(intergraph)library(dplyr)```## Challenge OverviewToday's challenge is to1) read in a dataset, and2) create a network object## Load the DataReading in the `got_marriages.csv` file:```{r}got_marriages<-read_csv("../posts/_data/got/got_marriages.csv")got_marriages```## Create a NetworkCreating an `igraph` object and finding out whether the network directed, weighted or bipartite.```{r}#| label: summary# not adjacency matrix, not n x n matrix => undirectedgot_marriages.ig <-graph_from_data_frame(got_marriages, directed =FALSE)head(got_marriages.ig)# describing the networkis_directed(got_marriages.ig)is_bipartite(got_marriages.ig)is_weighted(got_marriages.ig)```Thus, this network is undirected, unimodal, and unweighted.Now, I'll plot the network:```{r}# plotting the network plot(got_marriages.ig, edge.curved=.1, vertex.color ="orange")```