Description Usage Arguments Details Value Examples
View source: R/feature_engineering.R
Engineers features related to hashtags in Tweets.
1 2 | feature_hashtags(data, doc_id_field, text_field, top_num = 100L,
min_n = 2L)
|
data |
a dataframe or tibble containing the text data and document id |
doc_id_field |
unquoted field name identifying the field within the data that represents the unique document id |
text_field |
unquoted field name identifying the field name in data that contains the text of the Tweet |
top_num |
integer, the top n hashtags to create features from |
min_n |
integer, the minimum number of occurrences a hashtag must appear in the data |
Hashtags are first converted to lowercase before the features are calculated.
The hashtag features are calculated as a proportion of the total number of words in the Tweet:
the count of positive/negative sentiment based on the NRC lexicon
the count of positive/negative sentiment once all NRC lexicon sentiments are grouped
the count of the top n hashtags used in the training data
A data frame of document ids their associated hashtag features
1 2 3 4 5 6 | tweets <- data.frame(status_id = c(1234, 5678),
text = c("I tweet about one thing #onething #things",
"I tweet about another thing #another
thing #things"),
stringsAsFactors = FALSE)
feature_hashtags(tweets, status_id, text)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.