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 .
0
votes
1 Answers
0
votes
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: