Load Packages and Data

You can either paste chunks of code into the RStudio console, or paste it into a R script file and click run to run each line. You can put chunks into parentheses {} and it will run the whole chunk in sequence when you click run.

Copy and run the following in RStudio to load your packages:

library(sna)
library(readr)
library(igraph)
library(tidyverse)
library(tidygraph)
library(visNetwork)

To simulate using your own dataset, download this .csv to your local directory.

Now you can use the following command which uses readr to choose the file from your directory and open it into R.

# Bring the dataset into R as a dataframe
input_data<-read.csv(file.choose())

The contents of your .csv file will now be stored as an object called input_data and can be viewed in the “Environment” tab. You should see that there are 30 observations and 8 variables in the shared example.