[RStudio] 텍스트 마이닝 코드

Programming 2023. 11. 12. 20:09 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


install.packages("multilinguer")
library(multilinguer)


install.packages("remotes")
remotes::install_github("haven-jeon/KoNLP",
                         force = T,
                         upgrade = "never", 
                         INSTALL_opts = c("--no-multiarch"))


library("wordcloud")
library("RColorBrewer")
library(KoNLP)
useNIADic()
Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jre-1.8") # JAVA 환경 설정정
Sys.getenv("JAVA_HOME") # JAVA 환경 설정 확인

data1 <- readLines("c:/TEMP/wordcl1.csv")
data2 <- extractNoun(data1) # list 형태로 바뀜
data3 <- unlist(data2)
data3
data4 <- Filter(function(x) {
  nchar(x) <= 10 & nchar(x) > 1}, data3)
wordcount <- table(data4)
sort(wordcount, decreasing = T)
palete <- brewer.pal(9,"Set3")  
wordcloud(names(wordcount),
          freq=wordcount,
          scale=c(5,1),
          rot.per=0.25,
          min.freq=1, 
          random.order=F,
          random.color=T,
          colors=palete)