Is there any other package other than "sentiment" to do Sentiment Analysis in R?
Solution 1
I can't find sentiment
package.This is based on the tm.plugin.sentiment
package. You can find it here.
First, I create my Corpus:
some_txt<- c("I am very happy at stack overflow , excited, and optimistic.",
+ "I am very scared from OP question, annoyed, and irritated.")
text.corpus <- Corpus(VectorSource(some_txt))
Then, I apply score on the corpus
> text.corpus <- score(text.corpus)
The result is stored in the meta :
> meta(text.corpus)
MetaID polarity subjectivity pos_refs_per_ref neg_refs_per_ref senti_diffs_per_ref
1 0 0 0.2857143 0.1428571 0.1428571 0.0000000
2 0 -1 0.1428571 0.0000000 0.1428571 -0.1428571
behind the code The score
function (the default behavior), will pre-procees the corpus using these tm functions:
- tolower
- removePunctuation
- removeNumbers = TRUE,
- removeWords = list(stopwords("english")),
- stripWhitespace
- stemDocument
- minWordLength = 3,
Then, apply the score functions:
- polarity
- subjectivity
- pos_refs_per_ref
- neg_refs_per_ref
- senti_diffs_per_ref
Solution 2
There is new R package called sentiment140, required no additional component installation nor language model training.
- Easy to use
- work with Twitter Text
Cool stuff !
http://github.com/okugami79/sentiment140
Solution 3
This is what I did to install 'sentiment' 0.2 in R version 3.0.2
I downloaded the 'sentiment_0.2.tar.gz' from the repository http://cran.r-project.org/src/contrib/Archive/sentiment/
Then I've put the 'sentiment_0.2.tar.gz' in the main directory --> C:
Then I used the command to install packages from local zip:
install.packages("C:/sentiment_0.2.tar.gz", repos = NULL, type="source")
This is what I've got:
Warning in install.packages :
package ‘C:/sentiment_0.2.tar.gz’ is not available (for R version 3.0.2)
Installing package into ‘C:/Users/y65liu/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
** installing source package 'sentiment' ...
** package 'sentiment' successfully unpacked and MD5 sums checked
** R
** data
** preparing package for lazy loading
** help
** installing help indices
** building package indices
** testing if installed package can be loaded
** DONE (sentiment) ?
When I call the library, the library is regularly loaded with its related packages ('tm', 'Rstem')
You may found documentation on using the sentiment package here:
https://sites.google.com/site/miningtwitter/questions/sentiment/sentiment
user1946217
Updated on July 25, 2022Comments
-
user1946217 almost 2 years
The "sentiment" package in R was removed from the Cran repository. What are the other packages which can do Sentiment Analysis?
For example, how I can rewrite this using other packages?
library(sentiment) # CLASSIFY EMOTIONS classify_emotion(some_txt,algorithm="bayes",verbose=TRUE) # classify polarity class_pol = classify_polarity(some_txt, algorithm="bayes")
Where documents here is defined as:
# DEFINE text some_txt<- c("I am very happy at stack overflow , excited, and optimistic.", "I am very scared from OP question, annoyed, and irritated.")
-
neilfws about 10 yearsThat links to the package which the OP already told us is no longer in CRAN.
-
Napmi almost 10 yearsYes but you can find it at the archives and then install the package manually in R
-
lawyeR about 9 yearsEach time the score() code throws an error: scored <- score(corpus.txt) Error in polarity.TermDocumentMatrix(list(i = c(2L, 6L, 8L, 11L, 12L, : could not find function "tm_tag_score". Others have encountered different errors: stackoverflow.com/questions/24612080/…. Can you advise or should I post a new question? Thank you.