Find common words
Say you want to visualize common words across multiple documents. You can do this with commonality.cloud().
Each of our coffee and chardonnay corpora is composed of many individual tweets. To treat the coffee tweets as a single document and likewise for chardonnay, you paste() together all the tweets in each corpus along with the parameter collapse = " ". This collapses all tweets (separated by a space) into a single vector. Then you can create a single vector containing the two collapsed documents.
a_single_string <- paste(a_character_vector, collapse = " ")
Once you're done with these steps, you can take the same approach you've seen before to create a VCorpus() based on a VectorSource from the all_tweets object.
이 연습은 강의의 일부입니다
Text Mining with Bag-of-Words in R
연습 안내
- Create
all_coffeeby usingpaste()withcollapse = " "oncoffee_tweets$text. - Create
all_chardonnayby usingpaste()withcollapse = " "onchardonnay_tweets$text. - Create
all_tweetsusingc()to combineall_coffeeandall_chardonnay. Makeall_coffeethe first term. - Convert
all_tweetsusingVectorSource(). - Create
all_corpusby usingVCorpus()onall_tweets.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create all_coffee
___ <- ___(___, ___)
# Create all_chardonnay
___ <- ___(___, ___)
# Create all_tweets
___ <- ___(___, ___)
# Convert to a vector source
___ <- ___(___)
# Create all_corpus
___ <- ___(___)