Learn R Programming

graphTweets (version 0.5.3)

gt_edges_from_text: Edges from text

Description

Get edges from data.frame of tweets.

Usage

gt_edges_from_text(data, id, source, tweets, ...)

gt_edges_from_text_( data, id = "status_id", source = "screen_name", tweets = "text", ... )

Arguments

data

Data.frame of tweets, usually returned by the rtweet package.

id

tweets unique id.

source

Author of tweets.

tweets

Column containing tweets.

...

any other column name.

Value

An object of class graphTweets.

Functions

  • gt_edges - Build networks of users.

  • gt_co_edges - Build networks of users to hashtags.

Details

The tl arguments stands for tolower and allows converting the #hashtags to lower case as these often duplicated, i.e.: #python #Python.

Examples

Run this code
# NOT RUN {
# simulate dataset
tweets <- data.frame(
  text = c("I tweet @you about @him and @her", 
           "I tweet @me about @you"),
  screen_name = c("me", "him"),
  retweet_count = c(19, 5),
  status_id = c(1, 2),
  hashtags = c("rstats", "Python"),
  stringsAsFactors = FALSE
)

tweets %>% 
  gt_edges_from_text(status_id, screen_name, text)
    
# }

Run the code above in your browser using DataLab