Venn Calculator

How to use Venn Calculator?

ggVennDiagram has a series of set operation functions, and this can be used as the Venn calculator.

library(ggVennDiagram)
set.seed(20231225)
y = list(
  A = sample(letters, 8) |> sort(),
  B = sample(letters, 8) |> sort(),
  C = sample(letters, 8) |> sort(),
  D = sample(letters, 8) |> sort())

y
#> $A
#> [1] "a" "e" "g" "o" "p" "s" "t" "v"
#> 
#> $B
#> [1] "a" "d" "f" "i" "k" "s" "y" "z"
#> 
#> $C
#> [1] "b" "g" "k" "o" "r" "s" "u" "w"
#> 
#> $D
#> [1] "b" "c" "e" "h" "k" "q" "s" "y"

First of all, we need to construct a Venn class object with this list. If you print this object, it will give meta information of the object.

venn_y = Venn(y)

venn_y
#> An object of class 'Venn':
#>    Slots: sets, names;
#>    No. Sets: 4   SetNames: A, B, C, D.

Combined results were provided as VennPlotData object.

pd = process_data(venn_y)
pd
#> Class VennPlotData - '401f'
#>   Type: ellipse; No. sets: 4; No. regions: 15.
#>   To view this shape, use `plot_shape_edge(get_shape_by_id('401f'))`.
#>   To view its components, use `venn_setedge()`, `venn_setlabel()`, etc.

Please note in order to keep the result concise, the containing items are nested. You may use the following methods to further process it.

Reference

Some of these above-mentioned functions are originally developed by Turgut Yigit Akyol in RVenn.