- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a Venn diagram in R?
A Venn diagram helps to identify the common and uncommon elements between two or more than two sets of elements. This is also used in probability theory to visually represent the relationship between two or more events. To create a Venn diagram in R, we can make use of venn function of gplots package.
Example
Consider the below vectors
x<-c(rep(c(1,2,3),times=c(4,5,8)),12,15,20) y<-c(1:10,25)
Installing and loading gplots package −
install.packages("gplots") library(gplots)
Creating the Venn diagram for x and y −
venn(list(x,y))
Output
If we have three variables then we will just add the third variable in venn function as shown below −
z<-c(5:15,21) venn(list(x,y,z))
Output
- Related Articles
- What is a Venn diagram
- Python Matplotlib Venn diagram
- How to create colored Venn Diagrams?
- How to create matrix diagram in R?
- How to Create a Use Case Diagram?
- How to create a sphere in R?
- How to modify the font size in Matplotlib-venn?
- How to create a frequency polygon in R?
- How to create a staircase plot in R?
- How to create a covariance matrix in R?
- How to create a polynomial model in R?
- How to create a sparse matrix in R?
- How to create a dummy variable in R?
- How to create permutations as a list in R?
- How to create a histogram using weights in R?

Advertisements