R : word cloud from dataframe

[ad_1]

Okay, so let’s picture we now have a dataframe with a uncooked textual content subject.

Step 1 cleansing knowledge

Let’s load cease phrases which we’ll take away from our textual content.

set up.packages("stopwords")
library("stopwords")
library(tidyverse)
library(tidytext)


freq_dataframe <- text_dataframe %>% unnest_tokens(phrase, textual content) %>% anti_join(stopwords("ru"))

#unnest_tokens - tokenize textual content
#anti_join - removes cease phrases

## You'll be able to select any language as a substitute of russian, "en", "es, "fr", ...

Step 2 Depend

count_dataframe = freq_dataframe %>% rely(phrase)
#phrase - is a subject of tokenized textual content

Step three Construct the cloud

set up.packages("wordcloud")
library("wordcloud")
wordcloud(phrases = count_dataframe$phrase, freq = count_dataframe$n, max.phrases = 300)

[ad_2]

Source link

Write a comment