Reputation: 775
I have some data as below, I would like to have Venn digram for them.Would you please let me know if there is any solution.
dim(a)
1200
dim(b)
420
dim(c)
580
dim(d)
650
a_b = 200
a_c=100
c_b=20
a_d= 11
b_d= 61
c_d= 0
Upvotes: 1
Views: 556
Reputation: 3914
There are multiple ways of building ViennDiagram. One is by using VennDiagram package:
library(VennDiagram)
grid.newpage()
venn.plot <- draw.quad.venn(
area1 = 1200,
area2 = 420,
area3 = 580,
area4 = 650,
n12 = 200,
n13 = 100,
n14 = 11,
n23 = 20,
n24 = 61,
n34 = 0,
n123 = 0,
n124 = 0,
n134 = 0,
n234 = 0,
n1234 = 0,
category = c("a", "b", "c", "d"),
fill = c("orange", "red", "green", "blue"),
lty = "dashed",
cex = 2,
cat.cex = 2,
cat.col = c("orange", "red", "green", "blue")
)
Upvotes: 3
Reputation: 2628
There are several tools to do just that. I developed one of them, called nVennR. With the data you have provided,
library(nVennR)
cVenn <- createVennObj(4, c("a", "b", "c", "d"))
cVenn <- setVennRegion(cVenn, c("a", "b"), 200)
cVenn <- setVennRegion(cVenn, c("a", "c"), 100)
cVenn <- setVennRegion(cVenn, c("c", "b"), 20)
cVenn <- setVennRegion(cVenn, c("a", "d"), 11)
cVenn <- setVennRegion(cVenn, c("b", "d"), 61)
cFig <- plotVenn(nVennObj = cVenn)
However, you can do the same in one line directly from the lists a, b, c and d:
plotVenn(list(a=a, b=b, c=c, d=d))
Upvotes: 0