I have four dataframes df1,df2,df3,df4 Each of them have two columns PROPERTIES , AVAILABLE PROPERTIES contains name of various properties and AVAILABLE has values 0 or 1 representing if the property is present . All dataframes have same same set of property names that is assured . I want a venn diagram having 4 circles with respective intersections signifying common properties . How to get this done .
Asked
Active
Viewed 1,336 times
0
-
[google R Venn Diagram](https://www.google.com/#q=R+venn+diagram&*&spf=1) – G5W Mar 19 '17 at 17:31
-
I did see a few examples but they are doing it by manually mentioning the intersection part , I have a huge dataset difficult to mention all intersecting areas manually – Aditya2956 Mar 19 '17 at 17:35
-
Provide sample data using dput(head(data, 20)) – Sathish Mar 19 '17 at 19:22
1 Answers
0
If I understand correctly, your data looks something like this:
ll <- lapply(1:4, function(x) {
data.frame(PROPERTIES = letters[1:8],
AVAILABLE = as.logical(rbinom(8, 1, 0.5)),
ind = x)
})
Notice that I'm using logicals instead of binaries.
First, let's reshape the data to something more useful.
library(dplyr)
library(tidyr)
dd <- bind_rows(ll) %>%
spread(ind, AVAILABLE)
Which gives us
> head(dd)
PROPERTIES 1 2 3 4
1 a TRUE FALSE TRUE TRUE
2 b TRUE FALSE FALSE TRUE
3 c FALSE FALSE FALSE FALSE
4 d TRUE TRUE TRUE FALSE
5 e TRUE TRUE FALSE FALSE
6 f TRUE FALSE TRUE TRUE
We can use the package eulerr
(that I have developed) to produce a euler diagram from this.
library(eulerr)
fit <- euler(dd[, -1])
plot(fit)
The result may look something like this:

Johan Larsson
- 3,496
- 18
- 34