我努力绘制一个简单的维恩图,但遇到了我不理解的错误。
与在Rdocumentation中为draw.triple.venn图功能编写的代码相比,我无法弄清楚代码中的错误(如下)-我认为代码很好(https://www.rdocumentation.org/packages/VennDiagram/versions/1.6.20/topics/draw.triple.venn)。
library(VennDiagram)
library(gridExtra)
body(draw.triple.venn)[[78]] <- substitute(cell.labels <- paste0(areas," : ", round( 100*areas/sum(areas), 1), "%"))
# this line of code adds %s to each of the cells in the Venn Diagram
g <- draw.triple.venn(
area1 = 2951,
area2 = 2764,
area3 = 2764,
n12 = 719,
n23 = 807,
n13 = 1034,
n123 = 325,
category = c("Mental Health", "Community", "Social Care"),
fill = c("blue", "red", "green"),
cat.col = c("blue", "red", "green"),
lty = "blank",
euler.d = TRUE,
scaled = TRUE,
cex = 2,
cat.cex = 2);
grid.arrange(gTree(children = g), main = "Breakdown of WSIC Service Users", sub = "By table")
我收到的无法理解的错误消息是:
Error in if (max.x - min.x >= max.y - min.y) { :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In sqrt(r1^2 - (l.x.cept.13 - x.centres[1])^2) : NaNs produced
2: In sqrt(r1^2 - (l.x.cept.13 - x.centres[1])^2) : NaNs produced
谢谢!
答案 0 :(得分:1)
有一个已报告的问题here的错误。我试图重现该示例,但出现相同的错误。如果您愿意尝试使用我的nVennR库,则可以得到如下图:
library(nVennR)
myV <- createVennObj(nSets = 3, sNames = c("Mental Health", "Community", "Social Care"), sSizes = c(0, 598, 913, 807, 873, 1034, 719, 325))
myV <- plotVenn(nVennObj = myV, borderWidth = 2, setColors = c('blue', 'red', 'green'))
有一些可视化参数,如您在vignette中所见。在这里,您还可以在sSizes
中找到数字的依据。
还有其他数据输入模式。最简单的方法是提供包含每个集合的元素的列表列表(您可以在插图的开头看到一个示例)。该软件包将为您计算图中的所有区域,然后您可以查询属于每个区域的元素。