< # 필요한 라이브러리 로드 install.packages(c("tidyverse", "tm", "KoNLP", "topicmodels", "LDAvis", "openxlsx")) library(tidyverse) library(tm) library(KoNLP) library(topicmodels) library(LDAvis) library(openxlsx) # 데이터 로드 data <- read.xlsx("C:/Rdata/jobplanet_우아한형제들.xlsx") # '총평', '장점', '단점' 열의 텍스트 추출 및 결합 texts <- c(data$총평, data$장점, data$단점) # 텍스트에서 2글자 이상의 명사 추출 word_list <- sapply(texts, function(x) {   nouns <- extractNoun(x)   return(nouns[nchar(nouns) >= 2]) }) # Document-Term Matrix 생성 dtm <- DocumentTermMatrix(Corpus(VectorSource(word_list))) # LDA 토픽 모델링 (여기서는 5개의 토픽으로 설정) lda_model <- LDA(dtm, k = 5, control = list(seed = 1234)) # Normalize the rows of the phi matrix so that they sum to 1 phi_normalized <- lda_model@beta / rowSums(lda_model@beta) # 결과 시각화 vis <- LDAvis::createJSON(phi = phi_normalized,                            theta = lda_model@gamma,                            doc.length = rowSums(as.matrix(dtm)),                           vocab = dtm$dimnames$Terms,                           term.frequ>