0
文本挖掘關聯分析如何清除空間的關聯分析
如何清除空間
要查看關聯規則創建的結果,
有空白字符(左)。(例如這出現)
[1] {} => {monday} 0.012672811 0.012672811 1.000000
[2] {} => {happy} 0.007488479 0.007488479 1.000000
[3] {} => {money} 0.007488479 0.007488479 1.000000
它應該被刪除,當你使用「arulesViz圖」。
由於空格有很多未命名的圈子。
我該怎麼辦? 謝謝你的建議。
library(KoNLP)
library(RColorBrewer)
library(wordcloud)
text1<-readLines(file.choose())
text1
Encoding(text1)<- "UTF-8"
text1 <- readLines(text1)
lword <- Map(extractNoun,text1)
lword <- unique(lword)
lword <- sapply(lword, unique)
filter1 <- function(x){
nchar(x) <= 4 && nchar(x) >= 2 && is.hangul(x)
}
filter2 <- function(x){
Filter(filter1, x)
}
lword <- sapply(lword, filter2)
install.packages("arules")
library(arules)
wordtran <- as(lword, "transactions")
wordtable <- crossTable(wordtran)
tranrules <- apriori(wordtran, parameter=list(supp=0.01, conf=0.05))
inspect(tranrules)
rules <- labels(tranrules, ruleSep=" ")
rules <- sapply(rules, strsplit, " ", USE.NAMES=F)
rulemat <- do.call("rbind", rules)
#---------------------------------------------
#▽Association analysis visualization
#---------------------------------------------
install.packages("arulesViz")
library(arulesViz)
plot(tranrules, method="graph", control=list(type="items"))