<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=R%3A_tidytext%3A_sentiment_analysis_basic</id>
	<title>R: tidytext: sentiment analysis basic - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=R%3A_tidytext%3A_sentiment_analysis_basic"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=R:_tidytext:_sentiment_analysis_basic&amp;action=history"/>
	<updated>2026-04-21T01:21:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=R:_tidytext:_sentiment_analysis_basic&amp;diff=57716&amp;oldid=prev</id>
		<title>Onnowpurbo: Created page with &quot; # Ref: https://github.com/dgrtwo/tidy-text-mining/blob/master/02-sentiment-analysis.Rmd   install.packages(&quot;textdata&quot;)   library(knitr)  opts_chunk$set(message = FALSE, warni...&quot;</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=R:_tidytext:_sentiment_analysis_basic&amp;diff=57716&amp;oldid=prev"/>
		<updated>2019-12-03T00:52:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; # Ref: https://github.com/dgrtwo/tidy-text-mining/blob/master/02-sentiment-analysis.Rmd   install.packages(&amp;quot;textdata&amp;quot;)   library(knitr)  opts_chunk$set(message = FALSE, warni...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; # Ref: https://github.com/dgrtwo/tidy-text-mining/blob/master/02-sentiment-analysis.Rmd&lt;br /&gt;
&lt;br /&gt;
 install.packages(&amp;quot;textdata&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 library(knitr)&lt;br /&gt;
 opts_chunk$set(message = FALSE, warning = FALSE, cache = TRUE)&lt;br /&gt;
 options(width = 100, dplyr.width = 100)&lt;br /&gt;
 library(ggplot2)&lt;br /&gt;
 theme_set(theme_light())&lt;br /&gt;
&lt;br /&gt;
 library(tidytext)&lt;br /&gt;
 get_sentiments(&amp;quot;afinn&amp;quot;)&lt;br /&gt;
 get_sentiments(&amp;quot;bing&amp;quot;)&lt;br /&gt;
 get_sentiments(&amp;quot;nrc&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ## Sentiment analysis with inner join&lt;br /&gt;
 library(janeaustenr)&lt;br /&gt;
 library(dplyr)&lt;br /&gt;
 library(stringr)&lt;br /&gt;
 tidy_books &amp;lt;- austen_books() %&amp;gt;%&lt;br /&gt;
   group_by(book) %&amp;gt;%&lt;br /&gt;
   mutate(linenumber = row_number(),&lt;br /&gt;
          chapter = cumsum(str_detect(text, regex(&amp;quot;^chapter [\\divxlc]&amp;quot;, &lt;br /&gt;
                                                  ignore_case = TRUE)))) %&amp;gt;%&lt;br /&gt;
   ungroup() %&amp;gt;%&lt;br /&gt;
   unnest_tokens(word, text)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #  First, let&amp;#039;s use the NRC lexicon and `filter()` for the joy words&lt;br /&gt;
 nrc_joy &amp;lt;- get_sentiments(&amp;quot;nrc&amp;quot;) %&amp;gt;% &lt;br /&gt;
   filter(sentiment == &amp;quot;joy&amp;quot;)&lt;br /&gt;
 tidy_books %&amp;gt;%&lt;br /&gt;
   filter(book == &amp;quot;Emma&amp;quot;) %&amp;gt;%&lt;br /&gt;
   inner_join(nrc_joy) %&amp;gt;%&lt;br /&gt;
   count(word, sort = TRUE)&lt;br /&gt;
&lt;br /&gt;
 # Next, let&amp;#039;s `filter()` the data frame with the text from the books&lt;br /&gt;
 # for the words from *Emma* and then use `inner_join()`&lt;br /&gt;
 # to perform the sentiment analysis.&lt;br /&gt;
 nrc_joy &amp;lt;- nrc %&amp;gt;% &lt;br /&gt;
   filter(sentiment == &amp;quot;joy&amp;quot;)&lt;br /&gt;
 tidy_books %&amp;gt;%&lt;br /&gt;
   filter(book == &amp;quot;Emma&amp;quot;) %&amp;gt;%&lt;br /&gt;
   inner_join(nrc_joy) %&amp;gt;%&lt;br /&gt;
   count(word, sort = TRUE)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 # calculate sentiment using spread()&lt;br /&gt;
 library(tidyr)&lt;br /&gt;
 jane_austen_sentiment &amp;lt;- tidy_books %&amp;gt;%&lt;br /&gt;
   inner_join(get_sentiments(&amp;quot;bing&amp;quot;)) %&amp;gt;%&lt;br /&gt;
   count(book, index = linenumber %/% 80, sentiment) %&amp;gt;%&lt;br /&gt;
   spread(sentiment, n, fill = 0) %&amp;gt;%&lt;br /&gt;
   mutate(sentiment = positive - negative)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 # plot&lt;br /&gt;
 library(ggplot2)&lt;br /&gt;
 ggplot(jane_austen_sentiment, aes(index, sentiment, fill = book)) +&lt;br /&gt;
   geom_col(show.legend = FALSE) +&lt;br /&gt;
   facet_wrap(~book, ncol = 2, scales = &amp;quot;free_x&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Referensi==&lt;br /&gt;
&lt;br /&gt;
* https://github.com/dgrtwo/tidy-text-mining/blob/master/02-sentiment-analysis.Rmd&lt;br /&gt;
&lt;br /&gt;
==Pranala Menarik==&lt;br /&gt;
&lt;br /&gt;
* [[R]]&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>