tw_network: Creates graph (directed)

Description Usage Arguments Details Value Author(s) Examples

View source: R/networks.R

Description

Using the output of tw_extract() and the author of the message, creates a graph

Usage

1
2
tw_network(source, target, only.from = FALSE, exclude.self = TRUE,
  min.interact = 1, group = NULL, size = NULL, ignore.case = TRUE)

Arguments

source

Vector of screen_name

target

List of vectors of mentions (output from tw_extract)

only.from

Whether to filter the links to those only where source and target are in the source vector

exclude.self

Whether to exclude self-links

min.interact

Minimun number of interactions to consider (links below this number will be excluded)

group

Data frame with two columns: name & group

size

A data frame with two columns: name & size

ignore.case

When TRUE converts all of source and target to lower-case.

Details

The value column in the links dataframe (see Value) is computed as the number of connexions between the source and the target.

Value

A two-element list containing two data.frames, nodes and links of class tw_Class_graph (to be used with plot.tw_Class_graph(). The nodes data.frame includes two columns, id, name and group. The links data.frame includes three columns, source, target and value.

Author(s)

George G. Vega Yon

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
# Loading sample data and retrieving mentions
data(senate_tweets)
mentions <- tw_extract(senate_tweets$text, obj="mention")$mention

# Preparing data for size. Here we are just setting a random size for
# each vertex.
usrs<- tolower(senate_tweets$screen_name)
size <- data.frame(name=unique(usrs),
                   size=exp(runif(length(unique(usrs)))*5))

# Creating the graph
graph <- tw_network(
  usrs, mentions, min.interact = 5, size=size)

# Visualizing the graph
plot(graph)

## End(Not run)

gvegayon/twitterreport documentation built on May 17, 2019, 9:30 a.m.