Search code examples
rrstudiodata-analysis

How to create venn diagram in R studio from group of three frequency column


How to create a venn diagram in R from

dataFrame:

user  has_1  has_2  has_3
3431  true   false  true 
3432  false  true   false 
3433  true   false  false 
3434  true   false  false 
3435  true   false  false 
3436  true   false  false 

There are thousands such row.

I want to show how many users have has_1, has_2 and has_3 and their intersections as it is shown in Venn digram.


Solution

  • Here's one way to do it using the package venneuler:

    df <- read.table(header = TRUE, text = "user  has_1  has_2  has_3
    3431  true   false  true
    3432  false  true   false
    3433  true   false  false
    3434  true   false  false
    3435  true   false  false
    3436  true   false  false", colClasses = c("numeric", rep("logical", 3)))
    library(venneuler) 
    plot(venneuler(df[-1]))
    

    Look at this graph:

    enter image description here