小编sup*_*mbo的帖子

R igraph将平行边缘转换为权重属性

我正在使用igraph for R.我的图表基于一个包含平行边缘的边缘列表(多个边缘具有相同的源和目标).我想将这些平行边缘转换为边缘属性权重.有没有一种方法可以做到这一点?

如果没有简单的方法.如何识别这些平行边缘?

    duplicated(E(net))
Run Code Online (Sandbox Code Playgroud)

不会返回单个副本.我想它正在寻找重复的边缘ID.

r edges igraph weighted-graph

12
推荐指数
2
解决办法
5385
查看次数

对ggplot geom_text使用wordlayout结果

R包wordcloud有一个非常有用的功能,叫做wordlayout.它采用单词的初始位置及其各自的大小,以不重叠的方式重新排列它们.我想用这个函数的结果在ggplot中做一个geom_text图.我提出了以下示例,但很快就意识到,在cex(wordlayout)和size(geom_plot)之间似乎存在很大差异,因为图形包中的单词看起来更大.这是我的示例代码.Plot 1是原始的wordcloud图,没有重叠:

library(wordcloud)
library(tm)
library(ggplot2)

samplesize=100
textdf <- data.frame(label=sample(stopwords("en"),samplesize,replace=TRUE),x=sample(c(1:1000),samplesize,replace=TRUE),y=sample(c(1:1000),samplesize,replace=TRUE),size=sample(c(1:5),samplesize,replace=TRUE))

#plot1
plot.new()
pdf(file="plot1.pdf")
textplot(textdf$x,textdf$y,textdf$label,textdf$size)
dev.off()
#plot2
ggplot(textdf,aes(x,y))+geom_text(aes(label = label, size = size))
ggsave("plot2.pdf")
#plot3
new_pos <- wordlayout(x=textdf$x,y=textdf$y,words=textdf$label,cex=textdf$size)
textdf$x <- new_pos[,1]
textdf$y <- new_pos[,2]
ggplot(textdf,aes(x,y))+geom_text(aes(label = label, size = size))
ggsave("plot3.pdf")
#plot4
textdf$x <- new_pos[,1]+0.5*new_pos[,3]#this is the way the wordcloud package rearranges the positions. I took this out of the textplot function
textdf$y <- new_pos[,2]+0.5*new_pos[,4]
ggplot(textdf,aes(x,y))+geom_text(aes(label = label, size = size))
ggsave("plot4.pdf")
Run Code Online (Sandbox Code Playgroud)

有没有办法克服这个cex /大小差异,并重新使用wordlayout为ggplots?

size r ggplot2 word-cloud

6
推荐指数
1
解决办法
1286
查看次数

igraph中有向图的派系

我正在研究基于R中的跟随者关系的Twitter网络.在这个网络中,我想确定每个人中最大的团队的大小,可以在他或她的时间线中读取彼此的推文.因此我需要maximum.cliques.但是这个功能忽略了方向性.我知道它没有集成在igraph包中,但是有没有办法在有向网络中找到派系,每个节点都是主动和被动地相互连接的?

r directed-graph clique igraph

4
推荐指数
1
解决办法
2371
查看次数

尝试重启时Apache2"configtest failed"

我试图通过使用.htaccess文件来保护我的www文件夹中的目录,该文件没有任何影响所以我改变了行

    AllowOverride None
Run Code Online (Sandbox Code Playgroud)

在我的apache2.conf中

    AllowOverride All
Run Code Online (Sandbox Code Playgroud)

作为根.

现在我看到这不是正确的方法.当尝试使用重启apache时

    /etc/init.d/apache2 restart (or stop and start)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息:

    [FAIL] Starting web server: apache2 failed!
    [warn] The apache2 configtest failed. ... (warning).
    Output of config test was:
    apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on         line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared         object file: No such file or directory
    Action 'configtest' failed.
    The Apache error log may have more information.
Run Code Online (Sandbox Code Playgroud)

我再次将行更改为AllowOverride None,但问题仍然存在.apache2 error.log不包含任何信息.并且配置文件中的第140行是

    IncludeOptional mods-enabled/*.load …
Run Code Online (Sandbox Code Playgroud)

.htaccess debian apache2

4
推荐指数
1
解决办法
3万
查看次数