Convert Various Objects to network graphs.

as_tweet_network(
  x,
  target_class = target_class,
  all_status_data = all_status_data,
  all_user_data = all_user_data,
  ...
)

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

# S3 method for data.frame
as_tweet_network(
  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_network()
#> Network attributes: #> vertices = 1228 #> directed = TRUE #> hyper = FALSE #> loops = TRUE #> multiple = TRUE #> bipartite = FALSE #> total edges= 1234 #> missing edges= 0 #> non-missing edges= 1234 #> #> Vertex attribute names: #> vertex.names #> #> Edge attribute names not shown
tweet_df %>% as_proto_net() %>% as_tweet_network()
#> Network attributes: #> vertices = 1228 #> directed = TRUE #> hyper = FALSE #> loops = TRUE #> multiple = TRUE #> bipartite = FALSE #> total edges= 1234 #> missing edges= 0 #> non-missing edges= 1234 #> #> Vertex attribute names: #> vertex.names #> #> Edge attribute names not shown
tweet_df %>% as_tweet_network(all_status_data = TRUE)
#> Network attributes: #> vertices = 1228 #> directed = TRUE #> hyper = FALSE #> loops = TRUE #> multiple = TRUE #> bipartite = FALSE #> total edges= 1234 #> missing edges= 0 #> non-missing edges= 1234 #> #> Vertex attribute names: #> vertex.names #> #> Edge attribute names not shown
tweet_df %>% as_tweet_network(all_user_data = TRUE)
#> Network attributes: #> vertices = 1228 #> directed = TRUE #> hyper = FALSE #> loops = TRUE #> multiple = TRUE #> bipartite = FALSE #> total edges= 1234 #> missing edges= 0 #> non-missing edges= 1234 #> #> Vertex attribute names: #> account_created_at account_lang bbox_coords description favourites_count followers_count friends_count listed_count location name.y profile_banner_url profile_image_url profile_url protected screen_name statuses_count timestamp_ms url verified vertex.names #> #> Edge attribute names not shown