as_proto_net: Convert Various Objects to 'proto_net's

Description Usage Arguments Details Author(s) Examples

View source: R/proto_net.R

Description

A proto_net is a list containing two data frames named edges and nodes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
as_proto_net(
  tweet_df,
  target_class = c("user", "hashtag", "url", "media"),
  all_status_data = FALSE,
  all_user_data = FALSE,
  as_tibble = tweetio_as_tibble(),
  ...
)

## S3 method for class 'data.frame'
as_proto_net(
  tweet_df,
  target_class = c("user", "hashtag", "url", "media"),
  all_status_data = FALSE,
  all_user_data = FALSE,
  as_tibble = tweetio_as_tibble(),
  ...
)

## S3 method for class 'data.table'
as_proto_net(
  tweet_df,
  target_class = c("user", "hashtag", "url", "media"),
  all_status_data = FALSE,
  all_user_data = FALSE,
  as_tibble = tweetio_as_tibble(),
  ...
)

Arguments

tweet_df

A data frame of tweets, as obtained by read_tweets() or one of {rtweet}'s collection functions, e.g. rtweet::search_tweets().

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.

as_tibble

<logical>, Default: tweetio_as_tibble(). Whether a tibble::tibble() should be returned. Ignored if the {tibble} package is not installed.

...

Arguments passed to or from other methods.

Details

Author(s)

Brendan Knapp brendan.g.knapp@nps.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
path_to_tweet_file <- example_tweet_file()

tweet_df <- read_tweets(path_to_tweet_file)

tweet_df %>%
  as_proto_net(as_tibble = TRUE)

tweet_df %>% 
  as_proto_net(target_class = "hashtag", as_tibble = TRUE)
  
tweet_df %>% 
  as_proto_net(target_class = "url", as_tibble = TRUE)
  
tweet_df %>% 
  as_proto_net(target_class = "media", as_tibble = TRUE)
  
tweet_df %>% 
  as_proto_net(all_status_data = TRUE, all_user_data = TRUE, as_tibble = TRUE)

knapply/tweetio documentation built on Dec. 22, 2020, 7:15 p.m.