Book Image

R Data Analysis Cookbook

By : Viswa Viswanathan, Shanthi Viswanathan
Book Image

R Data Analysis Cookbook

By: Viswa Viswanathan, Shanthi Viswanathan

Overview of this book

<p>Data analytics with R has emerged as a very important focus for organizations of all kinds. R enables even those with only an intuitive grasp of the underlying concepts, without a deep mathematical background, to unleash powerful and detailed examinations of their data.</p> <p>This book empowers you by showing you ways to use R to generate professional analysis reports. It provides examples for various important analysis and machine-learning tasks that you can try out with associated and readily available data. The book also teaches you to quickly adapt the example code for your own needs and save yourself the time needed to construct code from scratch.</p>
Table of Contents (18 chapters)
R Data Analysis Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating adjacency matrices and edge lists


We can represent social network data in different formats. We cover two common representations: sparse adjacency matrices and edge lists.

Taking data from the Meetup.com social networking site (from the previous recipe in this chapter—Downloading social network data using public APIs), this recipe shows how you can convert a data frame with membership information into a sparse adjacency matrix and then to an edge list.

In this application, nodes represent users of Meetup.com and an edge connects two nodes if they are members of at least one common group. The number of common groups for a pair of people will represent the weight of the connection.

Getting ready

If you have not yet installed the Matrix package, you should do so now using the following code:

> install.packages("Matrix")

If you completed the prior recipe Downloading social network data using public APIs and have the meetup_users.Rdata file, you can use it. Otherwise, you can download that...