available_data {sentimentr} | R Documentation |
Get Available Data
Description
See available sentimentr data a data.frame. Note that
sentimentr_data
is the main function to be used but
available_data
is exposed to allow other packages to use the
functionality in a generic way.
Usage
available_data(regex = NULL, package = "sentimentr", ...)
sentimentr_data(regex = NULL, package = "sentimentr", ...)
Arguments
regex |
A regex to search for within the data columns. |
package |
The name of the package to extract data from. |
... |
Other arguments passed to |
Value
Returns a data.frame
Examples
sentimentr_data()
available_data() ## generic version for export
available_data(package = 'datasets')
sentimentr_data('^hu')
sentimentr_data('^(hu|kot)')
combine_data(sentimentr_data('^(hu|kot)')[[1]])
## Not run:
if (!require("pacman")) install.packages("pacman")
pacman::p_load(sentimentr, tidyverse, magrittr)
sentiment_data <- sentimentr_data('^hu') %>%
pull(Data) %>%
combine_data() %>%
mutate(id = seq_len(n())) %>%
as_tibble()
sentiment_test <- sentiment_data %>%
select(-sentiment) %>%
get_sentences() %$%
sentiment(., by = c('id'))
testing <- sentiment_data %>%
left_join(sentiment_test, by = 'id') %>%
as_tibble() %>%
mutate(
actual = sign(sentiment),
predicted = sign(ave_sentiment)
)
testing %$%
ftable(predicted, actual)
## End(Not run)
[Package sentimentr version 2.9.0 Index]