prepare_venn: Convert list to 'geom_venn' compatible data.frame

Description Usage Arguments Value Examples

View source: R/prepare_venn.R

Description

Using a list of sets, construct a data.frame with the correct format for geom_venn.

Usage

1

Arguments

l

list of up to 26 numeric or character vectors (i.e. sets) to compare. Within each set there must not be any duplicated elements. If the list is not named then capital letters starting from A to Z will be substituted as names.

...

Name-value pairs and other arguments to be passed to add_column. See Examples section for an example.

Value

Returns a data.frame with length(l) rows and at least three essential columns: column 1 is set_name with the names of each set, column 2 is elements contains the elements in each set, column 3 is count which defines the smallest and the largest set overlap which is used for the legend limits in geom_venn(type = 'continuous'). Any additional columns are added afterward.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
lst <- list(
  set1 = c(1:3),
  set2 = c(3:20),
  set3 = c(1, 20:66)
)

# Add an additional column called 'fill'
vd <- prepare_venn(lst, fill = c("blue", "red", "green"))

# Plot a Venn diagram
ggplot() +
  geom_venn(aes(set_name = set_name, elements = elements, fill = fill), data = vd) +
  scale_fill_identity()

csdaw/ggvd documentation built on Dec. 31, 2021, 6:14 p.m.