하고재비

[R] Word Cloud 본문

R Hadoop

[R] Word Cloud

DeadDE 2018. 2. 1. 16:25
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
26
27
28
29
30
31
32
33
34
35
36
37
38
install.packages("wordcloud")
library(wordcloud)
library(KoNLP)
useNIADic()
news <- readLines("gg.txt")
news
buildDictionary("NIADic","",data.frame("문대통령","ncn"))
noun <- extractNoun(news)
noun
 
#명사만 추출
noun1 <- extractNoun(noun)
print(noun1)
 
#벡터로 변환
noun2 <- unlist(noun1)
print(noun2)
 
#한자리 숫자의 단어 제외
noun3 <- noun2[nchar(noun2) >= 2]
noun3
 
nounCount <- table(noun3)
nounCount
 
nounCount2 <- head(sort(nounCount,decreasing = TRUE),15)
nounCount2
 
install.packages("RColorBrewer")
library(RColorBrewer)
 
palete <- brewer.pal(9,"Set1")
palete
 
wordcloud(names(nounCount2),freq = nounCount2, scale = c(4,1),rot.per = 0.25,min.freq = 2,
          random.order = FALSE,random.color = TRUE,colors = palete)
 
 
cs



'R Hadoop' 카테고리의 다른 글

[R]웹크롤링2  (0) 2018.02.01
[R]웹크롤링  (0) 2018.02.01
[R]ggmap  (0) 2018.02.01
[R] 한글 전처리기  (0) 2018.02.01
[R] 전처리기  (0) 2018.02.01
Comments