Description Usage Arguments Details Value Note Author(s) See Also Examples
View source: R/CreateSemanticNetwork.R
Create semantic networks from social media data (semantic relationships between concepts)
1 2 | CreateSemanticNetwork(x, writeToFile, termFreq, hashtagFreq,
removeTermsOrHashtags, stopwordsEnglish)
|
x |
a data frame of class |
writeToFile |
logical. If |
termFreq |
numeric integer, specifying the percentage of most frequent TERMS to include. For example, a value of 20 means that the 20 percent most frequently occurring terms will be included in the semantic network. The default value is 5, meaning the 5 percent most frequent terms are used. |
hashtagFreq |
** NOT IMPLEMENTED YET - DEFAULTS TO ALL HASHTAGS **. numeric integer, specifying the percentage of most frequent HASHTAGS to include. For example, a value of 80 means that the 80 percent most frequently occurring hashtags will be included in the semantic network. The default value is 50, meaning the 50 percent most frequent hashtags are used. |
removeTermsOrHashtags |
character vector. Default is none. Otherwise this argument specifies which terms or hashtags (i.e. vertices with matching 'name') should be removed from the semantic network. This is useful to remove the search term or hashtag that was used to collect the data (i.e. remove the corresponding vertex in the graph). For example, a value of "#auspol" means that if there is a vertex with the name "#auspol" then this vertex will be removed. |
stopwordsEnglish |
logical. If |
This function creates a semantic network from social media data (i.e. from
data frames of class dataSource
, or for Twitter data it is also
possible to provide a list of data frames). In such semantic networks,
concepts are words/terms extracted from the text corpus of social media data
(e.g. tweets on Twitter).
This function creates a weighted network from a data frame of class
dataSource
(which are created using the 'CollectData' family of
functions in the SocialMediaLab package), or a list of Twitter data frames
collected using CollectDataTwitter
function.
The resulting semantic network is an igraph graph object. This graph object is semantic because vertices represent unique concepts (in this case unique terms/words extracted from a social media text corpus), and edges represent the co-occurrence of terms for all observations in the data set. For example, for a Twitter semantic network, vertices represent either hashtags (e.g. "#auspol") or single terms ("politics"). If there are 1500 tweets in the data set (i.e. 1500 observations), and the term "#auspol" and the term "politics" appear together in every tweet, then this will be represented by an edge with weight equal to 1500.
An igraph graph object, with weighted edges.
Not all data sources in SocialMediaLab can be used for creating semantic networks.
Currently supported data sources are:
Other data sources (e.g. YouTube and Facebook) will be implemented in the future. Additionally, the user is notified if they try to create semantic networks for incompatible data sources.
For Twitter data, semantic networks can be created from multiple data frames
(i.e. datasets collected individually using CollectDataTwitter). Simply
create a list of the data frames that you wish to create a network from. For
example, myList <- list(myTwitterData1, myTwitterData2,
myTwitterData3)
.
Timothy Graham <timothy.graham3@uq.net.au> & Robert Ackland <robert.ackland@anu.edu.au>
See CollectDataTwitter
to collect data for creating semantic
networks in SocialMediaLab.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
## This example shows how to collect Twitter data and create a semantic network
# Firstly specify your API credentials
my_api_key <- "1234567890qwerty"
my_api_secret <- "1234567890qwerty"
my_access_token <- "1234567890qwerty"
my_access_token_secret <- "1234567890qwerty"
# Authenticate with the Twitter API using \code{AuthenticateWithTwitterAPI}
AuthenticateWithTwitterAPI(api_key=my_api_key, api_secret=my_api_secret,
access_token=my_access_token, access_token_secret=my_access_token_secret)
# Collect tweets data using \code{myTwitterData}
myTwitterData <- CollectDataTwitter(searchTerm="#auspol",
numTweets=200,writeToFile=FALSE,verbose=FALSE)
# Create a 'semantic' network using \code{CreateSemanticNetwork}
g_semantic_twitter <- CreateSemanticNetwork(myTwitterData,writeToFile=FALSE,
termFreq=20,hashtagFreq=80)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.