R//中的文本挖掘如何添加关联分析权重
我正在与TXT文件进行链接分析。我的代码现在都一样了。没有迹象表明哪个项目更相关。
如果要增加圆圈大小,= 高频
我想增加线的粗细=高支撑。我该怎么办?
谢谢你的建议。
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("igraph")
library(igraph)
ruleg <- graph.edgelist(rulemat[c(12:59),], directed=F)
plot.igraph(ruleg, vertex.label=V(ruleg)$name,
vertex.label.cex=1.2, vertex.label.color='black',
vertex.size=20, vertex.color='gray', vertex.frame.color='blue')
你可以做
library(igraph)
g <- sample_pa(10)
V(g)$freq <- runif(vcount(g), 1, 10)
E(g)$supp <- rnorm(ecount(g))
vsize <- c(10, 20)
esize <- c(1, 5)
plot(
g,
vertex.size=scales::rescale(V(g)$freq, vsize),
edge.width=scales::rescale(E(g)$supp, esize)
)