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 to do it...

To create adjacency matrices and edge lists, follow these steps:

  1. Load Meetup.com user information from the meetup_users.Rdata file. This creates a data frame called users which has the variables, (user_id and group_id):
> load("meetup_users.Rdata") 
  1. Create a sparse matrix with groups on the rows and users on the columns with TRUE on each (group_id,user_id) position, where the group has the user as a member. If you have a large number of users, this step will take a long time. It also needs a lot of memory to create a sparse matrix. If your R session freezes, you will have to either find a computer with more RAM or reduce the number of users and try again:
> library(Matrix) > grp.membership = sparseMatrix(users$group_id, ...

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