Session Ready
Exercise

What Makes an Important Product?

Now that we've come up with a working definition of an important product, let's see if they have any properties that might be correlated. One candidate pairing is salesrank.from and salesrank.to. We can ask if important products tend to have higher sales ranks than the products people purchase downstream. We'll look at this by first subsetting out the important vertices, joining those back to the initial dataframe, and then creating a new dataframe using the package dplyr. We'll create a new graph, and color the edges blue for high ranking (1, 2, 3) to low ranking (20, 21, 22) and red for the opposite. If rank is correlated with downstream purchasing, then we'll see mostly blue links, and if there's no relationship, it will be about equally red and blue.

The dataset ip_df contains the information about important products.

Instructions 1/2
undefined XP
  • 1
  • 2
  • Select the from and to columns from ip_df, assigning to ip_df_from_to.
  • Use graph_from_data_frame() to create a directed graph from ip_df_from_to.
  • Define the edge color to be blue if ip_df$salesrank.from is less than or equal to ip_df$salesrank.to, and red otherwise.