Type: Package
Title: Visualise Twitter Interactions
Version: 0.5.3
Date: 2020-01-02
Description: Allows building an edge table from data frame of tweets, also provides function to build nodes and another create a temporal graph.
License: MIT + file LICENSE
Depends: R (≥ 3.2.0)
Imports: dplyr, igraph, purrr, rlang, magrittr, utils, tidyr, zeallot, combinat
RoxygenNote: 7.0.2
URL: http://graphTweets.john-coene.com
BugReports: https://github.com/JohnCoene/graphTweets/issues
Suggests: rtweet, testthat
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2020-01-07 12:45:28 UTC; jcoe
Author: John Coene [aut, cre]
Maintainer: John Coene <jcoenep@gmail.com>
Repository: CRAN
Date/Publication: 2020-01-08 09:00:08 UTC

graphTweets visualise Twitter Interactions.

Description

graphTweets visualise Twitter Interactions.

Functions

Examples

## Not run: 
library(rtweet)

tweets <- search_tweets("#rstats")

library(graphTweets)

# simple network
tweets %>% 
  gt_edges(screen_name, mentions_screen_name) %>% # get edges
  gt_nodes %>% # get nodes
  gt_graph %>% # build igraph object
  plot(.)

## End(Not run)


Collect

Description

Collect

Usage

gt_collect(gt)

Arguments

gt

An object of class graphTweets as returned by gt_edges and gt_nodes.

Value

A named list of tibble 1) edges and 2) nodes.

Examples

# simulate dataset
tweets <- data.frame(
  text = c("I tweet @you about @him", 
           "I tweet @me about @you"),
  screen_name = c("me", "him"),
  retweet_count = c(19, 5),
  status_id = c(1, 2),
  stringsAsFactors = FALSE
)

tweets %>% 
  gt_edges(text, screen_name, status_id) %>% 
  gt_nodes() %>% 
  gt_collect() -> net


Dynamise

Description

Create a dynamic graph to import in Gephi.

Usage

gt_dyn(gt, lifetime = Inf)

Arguments

gt

An object of class graphTweets as returned by gt_edges and gt_nodes.

lifetime

Lifetime of a tweet in milliseconds, defaults to Inf.

Examples

## 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"),
  created_at = c(Sys.time(), Sys.time() + 10000),
  status_id = c(1, 2),
  stringsAsFactors = FALSE
)

tweets %>% 
  gt_edges(text, screen_name, status_id, "created_at") %>% 
  gt_nodes() %>% 
  gt_dyn() %>% 
  gt_collect() -> net

## End(Not run)


Edges

Description

Get edges from data.frame of tweets.

Usage

gt_edges(data, source, target, ..., tl = TRUE)

gt_preproc_edges(gt, func)

gt_edges_bind(gt, source, target, ..., tl = TRUE)

gt_co_edges(data, col, tl = TRUE)

gt_co_edges_bind(gt, col, tl = TRUE)

Arguments

data

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

source

Author of tweets.

target

Edges target.

...

any other column name, see examples.

tl

Set to TRUE to convert source and target to lower case (recommended).

gt

An object of class graphTweets as returned by gt_edges and gt_nodes.

func

Function to pre-process edges, takes edges as constructed by gt_edges, includes columns named source target and others passed to the three dot construct.

col

Column containing co-mentions.

Functions


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.

Details

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

Value

An object of class graphTweets.

Functions

Examples

# 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)
    

Graph

Description

Build igraph object.

Usage

gt_graph(gt)

Arguments

gt

An object of class graphTweets as returned by gt_edges and gt_nodes.

Value

An object of class igraph.

Examples

# simulate dataset
tweets <- data.frame(
  text = c("I tweet @you about @him", 
           "I tweet @me about @you"),
  screen_name = c("me", "him"),
  retweet_count = c(19, 5),
  status_id = c(1, 2),
  stringsAsFactors = FALSE
)

tweets %>% 
  gt_edges(text, screen_name, status_id) %>% 
  gt_nodes() %>% 
  gt_graph() -> net


Nodes

Description

Get nodes from a graphTweets object.

Usage

gt_nodes(gt, meta = FALSE)

gt_add_meta(gt, name, source, target)

Arguments

gt

An object of class graphTweets as returned by gt_edges and gt_nodes.

meta

Set to TRUE to add meta data to nodes using users_data.

name

Name of column to create.

source, target

Name of column too apply to edge source and target.

Value

An object of class graphTweets.

Functions


Save

Description

Save the graph to file.

Usage

gt_save(gt, file = "graphTweets.graphml", format = "graphml", ...)

Arguments

gt

An object of class graphTweets as returned by gt_edges and gt_nodes.

file

File name including extension (format).

format

Format file format, see write_graph.

...

Any other argument to pass to write_graph.

Examples

## Not run: 
# simulate dataset
tweets <- data.frame(
  text = c("I tweet @you about @him", 
           "I tweet @me about @you"),
  screen_name = c("me", "him"),
  retweet_count = c(19, 5),
  created_at = c(Sys.time(), Sys.time() + 15000),
  status_id = c(1, 2),
  stringsAsFactors = FALSE
)

tweets %>% 
  gt_edges(text, screen_name, "created_at") %>% 
  gt_nodes(TRUE) %>% 
  gt_dyn() %>% 
  gt_save()

## End(Not run)


Objects exported from other packages

Description

These objects are imported from other packages. Follow the links below to see their documentation.

magrittr

%>%

zeallot

%<-%