Question: library ( tidyverse ) #data manipulation & plotting library ( stringr ) # text cleaning and regular expressions library ( tidytext ) # provides additional

library(tidyverse) #data manipulation & plotting
library(stringr) # text cleaning and regular expressions
library(tidytext) # provides additional text mining functions
LOTR - readRDS("LOTR.RDS") ## read in the text of
stop_words - tidytext::stop_words
tokens - LOTR %>% unnest_tokens (word, text)
tokens - tokens %> dplyr::filter(!word %in% stop_words $ word )
all_word_counts - tokens %>% group_by(book, chapter)%>%
count (word, sort = TRUE)%>% ungroup
all_word_counts_mat - all_word_counts %% spread (key=word, value=n, fill=0)
word_counts - all_word_counts_mat [["ring"]]
Plot the log-likelihood of the Poisson rate of usage of the word in word_counts. Then use word_counts
to compute the maximum likelihood estimate of the rate of the usage of the word in the LOTR. Mark
this maximum on the log-likelihood plot with a vertical line (use abline if you make the plot in base R or
geom_vline if you prefer ggplot).
 library(tidyverse) #data manipulation & plotting library(stringr) # text cleaning and regular

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!