简体   繁体   English

R 维恩图错误 - 三重维恩图

[英]R Venn Diagram error - triple venn diagram

I struggling to draw a simple Venn diagram, and I'm getting errors that I do not understand.我努力绘制一个简单的维恩图,并且遇到了我不理解的错误。

I cannot work out what is wrong in my codes (below) compared to the one written in the Rdocumentation for the draw.triple.venn diagram function - the code is fine in my opinion ( https://www.rdocumentation.org/packages/VennDiagram/versions/1.6.20/topics/draw.triple.venn ).与 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")

The error message that I get, and cannot work out what it means is:我得到的错误消息,无法弄清楚它的含义是:

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 - (lxcept.13 - x.centres[1])^2) : NaNs produced 2: In sqrt(r1^2 - (lxcept.13 - x.centres[1])^2) : NaNs produced if (max.x - min.x >= max.y - min.y) { 中的错误:需要 TRUE/FALSE 的缺失值另外:警告消息:1:在 sqrt(r1^2 - (lxcept.13 - x.centres[1])^2) :产生的 NaN 2:在 sqrt(r1^2 - (lxcept.13 - x.centres[1])^2) 中:产生的 NaN

Thank you!谢谢!

There is a reported bug with this issue here . 此处报告了此问题的错误。 I have tried to reproduce the example and I get the same error.我试图重现这个例子,我得到了同样的错误。 If you are willing to try my nVennR library, you can get the diagram like this:如果你愿意尝试我的 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'))

The result is an SVG file:结果是一个 SVG 文件: 三重维恩图

There are some visualization parameters, as you can see in the vignette .正如您在小插图中看到的那样,有一些可视化参数。 There, you can also find the rationale for the numbers in sSizes .在那里,您还可以找到sSizes中数字的基本原理。 There are other modes of data entry.还有其他数据输入方式。 The easiest way is to provide a list of lists with the elements of each set (you can see one example at the beginning of the vignette).最简单的方法是提供包含每个集合元素的列表列表(您可以在小插图开头看到一个示例)。 The package will calculate all the regions in the diagram for you, and then you can query the elements belonging to each region.该包将为您计算图表中的所有区域,然后您可以查询属于每个区域的元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM