Rows: 46 Columns: 49
-- Column specification --------------------------------------------------------
Delimiter: ","
chr (3): Current house, Former house, Name
dbl (46): Lysa Arryn, Petyr Baelish, Joffrey Baratheon, Margaery Tyrell, Ren...
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Load the package `igraph` and create an `igraph` object (i.e. a graph or network) in the form of an edge list. The command may vary whether the data is given as a list of connections or an adjacency matrix. Is the network directed or undirected; weighted or unweighted; unimodal or bipartite? Can you plot it?
Code
library(igraph)
Warning: package 'igraph' was built under R version 4.1.3
Attaching package: 'igraph'
The following objects are masked from 'package:stats':
decompose, spectrum
The following object is masked from 'package:base':
union
Warning in graph_from_data_frame(got_like_dislike, directed = TRUE): In `d' `NA'
elements were replaced with string "NA"
Code
# Check if the network is directed or undirected, weighted or unweighted, unimodal or bipartiteis_bipartite(net.igraph)
[1] FALSE
Code
is_weighted(net.igraph)
[1] FALSE
Code
is_directed(net.igraph)
[1] TRUE
Code
plot(net.igraph)
Source Code
---title: "Week1_Challenge"author: "Rahul Gundeti"description: "Loading Data and Creating a Network"date: "02/13/2023"format: html: toc: true code-fold: true code-copy: true code-tools: true# editor: visualcategories: - challenge_1 - instructions---```{r}#| label: setup#| include: false```#### Challenge OverviewThis Challenge is to1\) Read a dataset, and2\) Create a network object#### Loading the dataRead in one (or more) of the following data sets, using the correct R package and command.\- got_marriages.csv\- fish_encounters dataset (available in the \`tidyr\` package)\- got_like_dislike.csv```{r}library(readr)got_like_dislike <-read_csv("_data/got/got_like_dislike.csv")head(got_like_dislike)```#### Creating a networkLoad the package \`igraph\` and create an \`igraph\` object (i.e. a graph or network) in the form of an edge list. The command may vary whether the data is given as a list of connections or an adjacency matrix. Is the network directed or undirected; weighted or unweighted; unimodal or bipartite? Can you plot it?```{r}library(igraph)net.igraph <-graph_from_data_frame(got_like_dislike, directed =TRUE)# Check if the network is directed or undirected, weighted or unweighted, unimodal or bipartiteis_bipartite(net.igraph)is_weighted(net.igraph) is_directed(net.igraph) plot(net.igraph)```