O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

Step 1 loads the saved network data in the form of an edge list.

With so much data, we will not find a plot to be a useful visual aid because it will be too cramped. Thus, for illustration, we redefine two users (nodes) to be related (connected in the social network) only if they have more than 16 group memberships in common.

Step 2 filters the edge list and retains only edges that meet the preceding criterion.

Although we have filtered the data, users still retain their original IDs, which are big numbers. Having user numbers in sequence starting with 1 might be nice.

Step 3 does this conversion.

Step 4 uses the graph.data.frame function from the igraph package to create a graph object. This function treats the first two ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required