Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Variational Inequalities And Frictional Contact Problems

Authors: Anca Capatina

1st Edition

3319101633, 9783319101637

More Books

Students also viewed these Mathematics questions

Question

Are the hours flexible or set?

Answered: 1 week ago

Question

1. Avoid conflicts in the relationship

Answered: 1 week ago

Question

1. What will happen in the future

Answered: 1 week ago