Convert Various Objects to igraph graphs.

as_tweet_igraph(
  x,
  target_class = c("user", "hashtag", "url", "media"),
  all_status_data = FALSE,
  all_user_data = FALSE,
  ...
)

as_igraph(
  x,
  target_class = c("user", "hashtag", "url", "media"),
  all_status_data = FALSE,
  all_user_data = FALSE,
  ...
)

# S3 method for proto_net
as_tweet_igraph(x, ...)

# S3 method for data.frame
as_tweet_igraph(
  x,
  target_class = c("user", "hashtag", "url", "media"),
  all_status_data = FALSE,
  all_user_data = FALSE,
  ...
)

Arguments

x

Tweet data frame or proto_net.

target_class

character(1L), Default: "user". The class of nodes to use as the second half of each dyad (target/to/head). See Details.

all_status_data

logical(1L), Default: FALSE. Whether to attach all relevant status data to the edges data frame, which can then be used as edge attributes for downstream tasks.

all_user_data

logical(1L), Default: FALSE. Whether to attach all relevant user data to the nodes data frame, which can then be uses as node attributes for downstream tasks.

...

Arguments passed to or from other methods.

See also

Examples

path_to_tweet_file <- example_tweet_file() tweet_df <- read_tweets(path_to_tweet_file) tweet_df %>% as_tweet_igraph()
#> IGRAPH 9ab2aa1 DN-- 1228 1234 -- #> + attr: name (v/c), status_id (e/c), relation (e/c) #> + edges from 9ab2aa1 (vertex names): #> [1] 194250838 ->340309688 #> [2] 825459487821619201 ->966825602 #> [3] 1116228559616397312->3153145782 #> [4] 4374655520 ->4167284315 #> [5] 1172885625068036102->1112877891841343488 #> [6] 1132474594583928832->1217220278 #> [7] 20737729 ->39334221 #> [8] 2198859787 ->3096758526 #> + ... omitted several edges
tweet_df %>% as_proto_net() %>% as_tweet_igraph()
#> IGRAPH 3574b90 DN-- 1228 1234 -- #> + attr: name (v/c), status_id (e/c), relation (e/c) #> + edges from 3574b90 (vertex names): #> [1] 194250838 ->340309688 #> [2] 825459487821619201 ->966825602 #> [3] 1116228559616397312->3153145782 #> [4] 4374655520 ->4167284315 #> [5] 1172885625068036102->1112877891841343488 #> [6] 1132474594583928832->1217220278 #> [7] 20737729 ->39334221 #> [8] 2198859787 ->3096758526 #> + ... omitted several edges
tweet_df %>% as_tweet_igraph(all_status_data = TRUE)
#> IGRAPH 07415a2 DN-- 1228 1234 -- #> + attr: name (v/c), status_id (e/c), relation (e/c), created_at (e/n), #> | text (e/c), status_url (e/c), source (e/c), is_quote (e/l), #> | is_retweeted (e/l), media_url (e/x), media_type (e/x), place_url #> | (e/c), place_name (e/c), place_full_name (e/c), place_type (e/c), #> | country (e/c), country_code (e/c), bbox_coords (e/x), status_type #> | (e/c) #> + edges from 07415a2 (vertex names): #> [1] 862716349054935040->845302547686526982 #> [2] 862716349054935040->845302547686526982 #> [3] 862716349054935040->1579930886 #> + ... omitted several edges
tweet_df %>% as_tweet_igraph(all_user_data = TRUE)
#> IGRAPH 9158173 DN-- 1228 1234 -- #> + attr: name (v/c), timestamp_ms (v/n), name.y (v/c), screen_name #> | (v/c), location (v/c), description (v/c), url (v/c), protected (v/l), #> | followers_count (v/n), friends_count (v/n), listed_count (v/n), #> | statuses_count (v/n), favourites_count (v/n), account_created_at #> | (v/n), verified (v/l), profile_url (v/c), account_lang (v/c), #> | profile_banner_url (v/c), profile_image_url (v/c), bbox_coords (v/x), #> | status_id (e/c), relation (e/c) #> + edges from 9158173 (vertex names): #> [1] 194250838 ->340309688 825459487821619201 ->966825602 #> [3] 1116228559616397312->3153145782 4374655520 ->4167284315 #> + ... omitted several edges