Learn R Programming

twitterreport (version 0.15.11)

tw_network: Creates graph (directed)

Description

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

Usage

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.

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.

Details

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

Examples

Run this code
## 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)

Run the code above in your browser using DataLab