Question
A famous poem authored by Robert Frost is The Road Not Taken. The poem is given below. Using r code of your choice, generate a
A famous poem authored by Robert Frost is The Road Not Taken. The poem is given below. Using r code of your choice, generate a word cloud for the poem.
This is what I have so far, I was able to generate a wordcloud, but only a couple words pop up and not all of them. Can you help me see how to put more words in the wordcloud?
library(textdata) library(tidytext) library(tm) library(SnowballC) library(wordcloud) library(RColorBrewer)
text <- c("Two roads diverged in a yellow wood,", "And sorry I could not travel both", "And be one traveler, long I stood", "And looked down one as far as I could", "To where it bent in the undergrowth;", "Then took the other, as just as fair,", "And having perhaps the better claim,", "Because it was grassy and wanted wear;", "Though as for that the passing there", "Had worn them really about the same,", "And both that morning equally lay", "In leaves no step had trodden black.", "Oh, I kept the first for another day!", "Yet knowing how way leads on to way,", "I doubted if I should ever come back.", "I shall be telling this with a sigh", "Somewhere ages and ages hence:", "Two roads diverged in a wood, and", "I took the one less traveled by,", "And that has made all the difference.")
text
text_tibble <- tibble(line = 108:127, text = text)
text_tibble
text_tibble %>% unnest_tokens(word, text) -> tibble2 tibble2
tibble2%>% count(word, sort =TRUE) %>% filter(n >= 4)
tibble3 <- tibble2 %>% count(word) %>% with(wordcloud(word, n, max.words = 1000)) view(tibble3)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started