Exploring your data set

Case Studies: Network Analysis in R

Edmund Hart

Instructor

library(igraph)
library(dplyr)
amzn_raw <- read.csv("datasets/amazon_purchase_no_book.csv")
head(amzn_raw)
    from to                     title.from group.from categories.from salesrank.from
1 1   44 42   The NBA's 100 Greatest Plays        DVD           33124              5
2 2  179 71 Africa Screams/Jack & The Bean        DVD           53825             21

  totalreviews.from totalreviews.1.from   
1                13                  13                                     
2                13                  13 

                                        title.to group.to
1                                         Pixote      DVD
2 Jonny Quest - Bandit in Adventures Best Friend    Video

  categories.to salesrank.to totalreviews.to totalreviews.1.to       date
1         19685           15              24                24 2003-03-02
2         21571            5               2                 2 2003-03-02
Case Studies: Network Analysis in R

Creating the graph

amzn_g <- amzn_raw %>% 
  filter(date == "2003-03-02") %>% 
  select(from, to) %>%
  graph_from_data_frame(directed = TRUE)

gorder(amzn_g) gsize(amzn_g)
Case Studies: Network Analysis in R

Visualize the graph

sg <- induced_subgraph(amzn_g, 1:500)
sg <- delete.vertices(sg, degree(sg) == 0)

plot(sg, vertex.label = NA, edge.arrow.width = 0, edge.arrow.size = 0, margin = 0, vertex.size = 2)

Case Studies: Network Analysis in R

Case Studies: Network Analysis in R

Case Studies: Network Analysis in R

Let's practice

Case Studies: Network Analysis in R

Preparing Video For Download...