youngwoos / Doit_R

<Do it! 쉽게 배우는 R 데이터 분석> 저장소
213 stars 436 forks source link

do.it.r 271페이지 #59

Closed hooo14 closed 3 years ago

hooo14 commented 3 years ago

library(KoNLP) library(dplyr) useNIADic() hiphop <- readLines("hiphop.txt") head(hiphop) hiphop <- str_replace_all(hiphop, "\W", " ") noun <- extractNoun(hiphop) wordcount <- table(unlist(noun)) df_word <- as.data.frame(wordcount,stringsAsFactors = F) df_word <- rename(df_word, word=Var1, freq=Freq) df_word <- filter(df_word, nchar(word)>=2) top20 <- df_word %>% arrange(desc(freq)) %>% head(20) top20 pal <- brewer.pal(8,"Dark2") set.seed(1234) wordcloud(words=df_word$word, freq=df_word$freq, min.freq=2, max.words = 200, random.order =F, rot.per=.1, scale=c(4,0.3), colors=pal)

이렇게 했는데 결과가 뜨문뜨문 나와요.. 사진은 어떻게 올리는지 모르겠어서요... 글자가 빼곡하고 동그랗게 안나오고 듬성듬성 네모네모하게 나와요

youngwoos commented 3 years ago

str_replace_all(hiphop, "\\W", " ") 이렇게 W\를 두 개 입력해보시겠어요?

작성한 코드와 캡쳐한 이미지를 아래 페이스북 데이터 분석 커뮤니티에 올려주세요. 보다 빨리 답변을 받아보실 수 있습니다.

데이터 분석 커뮤니티 https://www.facebook.com/groups/datacommunity/