Learn R Programming

SocialMediaLab (version 0.20.0)

CreateEgoNetwork: Create 'ego' networks from social media data

Description

This function creates 'ego' networks from social media data (currently only Instagram). The networks are igraph objects. The user provides a character vector of usernames, and the function collects data about the 'followers' of the users, with options to also collect data about who each user 'follows'. It also provides the ability to specify the 'degree' of the egonet (also sometimes known as the order), currently for 1-degree (ego + alters) or 2-degree (ego + alters + alters of alters of ego).

Usage

CreateEgoNetwork(dataSource, username, userid, verbose, degreeEgoNet,
  writeToFile, waitForRateLimit, getFollows)

Arguments

dataSource
character string, specifying which data source. Currently only "instagram" (default).
username
character vector, specifying a set of usernames who will be the 'ego' nodes for the network generation.
userid
numeric vector, specifying a set of user ids who will be the 'ego' nodes for the network generation. If usernames are already specified, this argument is ignored.
verbose
logical. If TRUE then this function will output runtime information to the console as it computes. Useful diagnostic tool for long computations. Default is FALSE.
degreeEgoNet
Numeric, the 'order' or 'degree' of the ego-network to create (1 is default). 1 = ego + alters. 2 = ego + alters + alters of alters.
writeToFile
logical. If TRUE then the network is saved to file in current working directory (GRAPHML format), with filename denoting the current date/time and the type of network.
waitForRateLimit
logical. If TRUE then it will try to observe the API rate limit by ensuring that no more than 5000 API calls are made per hour (the current rate limit). If more than 5000 calls are made within a 60 minute window, then all operates will suspen
getFollows
Logical, if TRUE (default), also collect who each 'ego' node itself follows (i.e. not just the followers of ego), and integrate these data into the ego network.

Value

  • An igraph graph object, with directed and weighted edges.

Details

This function creates a (weighted and directed) 'ego' network from a given set of seed users (the ego nodes).

The resulting network is an igraph graph object.

Note! The network size can become extremely large very quickly, depending on the arguments the user provides to this function. For example, specifying `degreeEgoNet=2` and `getFollows=TRUE` can generate very large networks from just a small number of ego users (even just 3 or 4 ego nodes).

See Also

See CollectDataYoutube and CollectDataTwitter to collect data sources for creating actor networks in SocialMediaLab.

Examples

Run this code
## Use your own values for myAppID and myAppSecret
  myAppID <- "123456789098765"
  myAppSecret <- "abc123abc123abc123abc123abc123ab"

  # Authenticate with the Instagram API using `AuthenticateWithInstagramAPI`
  instagram_oauth_token <- AuthenticateWithInstagramAPI(appID=app_id, appSecret=app_secret,
    useCachedToken=TRUE)

  myUsernames <- c("senjohnmccain","obama")

  g_ego_network <- CreateEgoNetwork(username=myUsernames,verbose=TRUE,degreeEgoNet=1,
    writeToFile=FALSE,waitForRateLimit=TRUE,getFollows=FALSE)

  # Description of actor network
  g_ego_network

Run the code above in your browser using DataLab