Instralling packages: wordcloud, manipulate
install.packages("wordcloud")
install.packages("tm")
#install.packages("slam")
install.packages("manipulate")
Sample Text
sample_text <- "From using dead spiders to grip objects to probing the weird feeling that occurs when the same word is written over and over again, researchers investigating some of the quirkiest conundrums in science have been honoured in this year’s Ig Nobel prizes.
Unlike the rather more stately Nobel prizes – which will be announced next month – the Ig Nobel prizes celebrate unusual areas of research that “make people laugh, then think”. They also come with a rather less majestic cheque: this year’s winning teams will each receive a 10 trillion dollar bill … from Zimbabwe.
Produced by the magazine Annals of Improbable Research, Thursday’s online ceremony featured real Nobel laureates awarding 10 Ig Nobel prizes to researchers around the world, with the award taking the form of a pdf document that could be printed and assembled to create a three-dimensional trophy."
sample_text
## [1] "From using dead spiders to grip objects to probing the weird feeling that occurs when the same word is written over and over again, researchers investigating some of the quirkiest conundrums in science have been honoured in this year’s Ig Nobel prizes.\n\nUnlike the rather more stately Nobel prizes – which will be announced next month – the Ig Nobel prizes celebrate unusual areas of research that “make people laugh, then think”. They also come with a rather less majestic cheque: this year’s winning teams will each receive a 10 trillion dollar bill … from Zimbabwe.\n\nProduced by the magazine Annals of Improbable Research, Thursday’s online ceremony featured real Nobel laureates awarding 10 Ig Nobel prizes to researchers around the world, with the award taking the form of a pdf document that could be printed and assembled to create a three-dimensional trophy."
Text Pre-processing
words <- unlist(strsplit(sample_text, "[[:space:]]|[[:punct:]]"))
words <- tolower(words)
(freq_data<-sort(table(words), decreasing=TRUE))
## words
## the nobel a of
## 18 9 5 4 4
## prizes to ig s that
## 4 4 3 3 3
## 10 and be from in
## 2 2 2 2 2
## over rather research researchers this
## 2 2 2 2 2
## will with year again also
## 2 2 2 1 1
## annals announced areas around assembled
## 1 1 1 1 1
## award awarding been bill by
## 1 1 1 1 1
## celebrate ceremony cheque come conundrums
## 1 1 1 1 1
## could create dead dimensional document
## 1 1 1 1 1
## dollar each featured feeling form
## 1 1 1 1 1
## grip have honoured improbable investigating
## 1 1 1 1 1
## is laugh laureates less magazine
## 1 1 1 1 1
## majestic make month more next
## 1 1 1 1 1
## objects occurs online pdf people
## 1 1 1 1 1
## printed probing produced quirkiest real
## 1 1 1 1 1
## receive same science some spiders
## 1 1 1 1 1
## stately taking teams then they
## 1 1 1 1 1
## think three thursday trillion trophy
## 1 1 1 1 1
## unlike unusual using weird when
## 1 1 1 1 1
## which winning word world written
## 1 1 1 1 1
## zimbabwe
## 1
Visualization 1: barplot
barplot(freq_data, las=3)

Visualization 2: wordcloud
library(wordcloud)
## Loading required package: RColorBrewer
wordcloud(rownames(freq_data),freq_data,min.freq=1,colors=brewer.pal(6,"Dark2"))

Intractive Visualization: barplot
library(manipulate)
manipulate(
barplot(freq_data, las=3, col=my_col),
my_col = picker("black", "blue", "green", "yellow","orange", "red")
)