GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — R/wordcloud.R at master · Twitter-Sentiment-Analysis/R

Expand file tree

/

wordcloud.R

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
25 lines (24 loc) · 1.25 KB
/

wordcloud.R

Copy path

File metadata and controls

25 lines (24 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
earthquake.tweets = searchTwitter("earthquake", lang="en", n=1500, resultType="recent")
earthquake_text = sapply(earthquake.tweets, function(x) x$getText())
df <- do.call("rbind", lapply(earthquake.tweets, as.data.frame))
earthquake_text <- sapply(df$text,function(row) iconv(row, "latin1", "ASCII", sub=""))
str(earthquake_text)
#corpus is a collection of text documents
library(tm)
quake_corpus <- Corpus(VectorSource(earthquake_text))
quake_corpus
inspect(quake_corpus[1])
#clean text
quake_clean <- tm_map(quake_corpus, removePunctuation)
quake_clean <- tm_map(quake_clean, content_transformation)
quake_clean <- tm_map(quake_clean, content_transformer(tolower))
quake_clean <- tm_map(quake_clean, removeWords, stopwords("english"))
quake_clean <- tm_map(quake_clean, removeNumbers)
quake_clean <- tm_map(quake_clean, stripWhitespace)
quake_clean <- tm_map(quake_clean, removeWords, c("Italy","earthquake"))#removing search words
#wordcloud
#wordcloud(quake_clean)
#wordcloud(quake_clean, random.order=F)
#wordcloud(quake_clean, random.order=F, scale=c(4,0.5))#max font size,min font size
#wordcloud(quake_clean, random.order=F,col=rainbow(50), scale=c(4,0.5))
wordcloud(quake_clean, random.order=F,max.words=80, col=rainbow(50), scale=c(4,0.5))
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.