Learn R Programming

vosonSML (version 0.29.13)

Create.twomode.twitter: Create twitter 2-mode network

Description

Creates a 2-mode network from tweets returned from the twitter search query. In this network there are two types of nodes, twitter users who authored or were mentioned in collected tweets and hashtags found within tweets. Network edges represent a users tweets that contain hashtags or mention users screen names.

The creation of twitter 2-mode networks requires text processing and the tokenization of tweets. As such this function requires the additional installation of the tidytext package to achieve this.

Usage

# S3 method for twomode.twitter
Create(
  datasource,
  type,
  removeTermsOrHashtags = NULL,
  weighted = TRUE,
  verbose = FALSE,
  ...
)

Value

Network as a named list of two dataframes containing $nodes and $edges.

Arguments

datasource

Collected social media data with "datasource" and "twitter" class names.

type

Character string. Type of network to be created, set to "twomode".

removeTermsOrHashtags

Character vector. Users or hashtags to remove from the twomode network. For example, this parameter could be used to remove the user or hashtag that was used to collect the data by removing any nodes with matching name. Default is NULL to remove none.

weighted

Logical. Add weights to network edges. If set to FALSE tweet status_id and created_at fields will be preserved for edges in the dataframe. Default is TRUE.

verbose

Logical. Output additional information about the network creation. Default is FALSE.

...

Additional parameters passed to function. Not used in this method.

Examples

Run this code
if (FALSE) {
# twitter 2-mode network creation additionally requires the tidytext package
# for working with text data
install.packages("tidytext")

# create a twitter 2-mode network graph removing the hashtag '#auspol' as it was used in 
# the twitter search query
twomodeNetwork <- twitterData %>% 
                  Create("twomode", removeTermsOrHashtags = c("#auspol"), verbose = TRUE)

# network
# twomodeNetwork$nodes
# twomodeNetwork$edges
}

Run the code above in your browser using DataLab