Learn R Programming

vosonSML (version 0.26.3)

Create.semantic.twitter: Create twitter semantic network

Description

Creates a semantic network from tweets returned from the twitter search query. Semantic networks describe the semantic relationships between concepts. In this network the concepts are significant words and terms (hashtags) extracted from the text corpus of the tweet data, and actors represented as nodes. Network edges are weighted and represent usage of frequently occurring terms and hashtags by the actors.

Usage

# S3 method for semantic.twitter
Create(datasource, type,
  removeTermsOrHashtags = NULL, stopwordsEnglish = TRUE,
  termFreq = 5, hashtagFreq = 50, writeToFile = FALSE,
  verbose = FALSE, ...)

Arguments

datasource

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

type

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

removeTermsOrHashtags

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

stopwordsEnglish

Logical. Removes English stopwords from the tweet data. Default is TRUE.

termFreq

Numeric integer. Specifies the percentage of most frequent terms to include. For example, a termFreq = 20 means that the 20 percent most frequently occurring terms will be included in the semantic network as nodes. A larger percentage will increase the number of nodes and therefore the size of graph. The default value is 5, meaning the top 5 percent most frequent terms are used.

hashtagFreq

Numeric integer. Specifies the percentage of most frequent hashtags to include. For example, a hashtagFreq = 80 means that the 80 percent most frequently occurring hashtags will be included in the semantic network as nodes. The default value is 50.

writeToFile

Logical. Save network data to a file in the current working directory. Default is FALSE.

verbose

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

...

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

Value

Named list containing semantic network as igraph object $graph.

Examples

Run this code
# NOT RUN {
# create a twitter semantic network graph removing the hashtag '#auspol' and using the
# top 2% frequently occurring terms and 10% frequently occurring hashtags as additional 
# concepts or nodes
semanticNetwork <- twitterData %>% 
                   Create("semantic", removeTermsOrHashtags = c("#auspol"), termFreq = 2,
                          hashtagFreq = 10, writeToFile = TRUE, verbose = TRUE)

# igraph object
# semanticNetwork$graph
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab