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 users group membership data from a meetup_users.Rdata saved file. This creates a users data frame with the (user_id,group_id) structure. From this, we want to create a network in which the nodes are users and a pair of users has an edge if they are members of at least one common group. We want to have the number of common group memberships as the weight of an edge.

Step 2 converts the information in the group membership data frame to a sparse matrix with groups on the rows and users on the columns. To clarify, the following table shows a sample matrix with four groups and nine users. The first group has users 1, 4, and 7 as members, while the second has users 1, 3, 4, and 6 as members, and so on. We have shown ...

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