gpt4 book ai didi

r - R中的4向维恩图?

转载 作者:行者123 更新时间:2023-12-01 04:42:45 27 4
gpt4 key购买 nike

我正在尝试在 R 中制作 4 路维恩图。我有这些数据要放入图表中:

enter image description here

谁能给我一个建议怎么做?我尝试使用函数 vennDiagram() 但这不起作用,因为它是一个 4way 图。

我也尝试使用 VennDiagram 包,但数据“分配”到图表中正确位置的方式确实令人困惑。我正在使用此代码:

library (VennDiagram)
venn.diagram(
x=list(
I=c(1:18,19:31,32:119,125:129,130:192,193:144,145:326,327:373),
VI=c(516:542,510:515,420:497,498:509,145:326,327:373,130:192,193:144),
II=c(19:31,32:119,145:326,327:373,374:378,378:419,420:497,498:509),
III=c(506:509,378:419,32:119,125:129,130:192,145:326,420:497,510:515)
),
filename = "4Way_Venn.tiff",
col = "black",
lty = "dotted",
lwd = 4,
fill = c("cornflowerblue", "green", "yellow", "darkorchid1"),
alpha = 0.50,
label.col = c("orange", "white", "darkorchid4", "white", "white", "white",
"white", "white", "darkblue", "white", "white", "white",
"white", "darkgreen", "white"),
cex = 2.5,
fontfamily = "serif",
fontface = "bold",
cat.col = c("darkblue", "darkgreen", "orange", "darkorchid4"),
cat.cex = 2.5,
cat.fontfamily = "serif"
);

谁能帮帮我?也许使用比使用 VennDiagram 包更简单的解决方案。

最佳答案

我可能在这里遗漏了重点,但我不确定您想如何在制作维恩图时使用这些“计数”?从 'c1' 到 'c4' 列,您可以使用 venneuler 非常轻松地制作维恩图。包装:

require(venneuler)
#here I replicate your data
#because it's repeatable, you can use `rep` function to generate it
c1 <- rep(c(0,1),each=8)
c2 <- rep(c(0,1),each=4,times=2)
c3 <- rep(c(0,1),each=2,times=4)
c4 <- rep(c(0,1),times=8)
#put your data into matrix
m <- as.matrix(data.frame(C1=c1,C2=c2,C3=c3,C4=c4))
#plot it
v = venneuler(m)
plot(v)

enter image description here

关于r - R中的4向维恩图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10111430/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com