Package 'amVennDiagram5'

Title: Interactive Venn Diagrams
Description: Creates interactive Venn diagrams using the 'amCharts5' library for 'JavaScript'. They can be used directly from the R console, from 'RStudio', in 'shiny' applications, and in 'rmarkdown' documents.
Authors: Stéphane Laurent [aut, cre], amCharts team [cph]
Maintainer: Stéphane Laurent <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2024-10-30 04:15:33 UTC
Source: https://github.com/stla/amvenndiagram5

Help Index


Enumeration of Venn diagrams

Description

Given the cardinalities of some sets, returns all possible Venn diagrams of these sets.

Usage

allVennDiagrams(cardinalities, output = "dataframes")

Arguments

cardinalities

vector of positive integers

output

either "lists" or "dataframes"

Value

List of Venn diagrams.


Venn diagram widget

Description

Creates an amVennDiagram widget.

Usage

amVennDiagram(
  data,
  theme = "default",
  legendPosition = "right",
  elementId = NULL
)

Arguments

data

a list such as one returned by makeVennData

theme

the theme: "default", "dark", "dataviz", "frozen", "kelly", "material", "moonrise", or "spirited"

legendPosition

legend position: "right" or "bottom"

elementId

a HTML id (usually useless)

Value

An amVennDiagram widget.

Examples

sets <- list(A = 1:20, B = 10:30, C = 15:35)
dat <- makeVennData(sets)
amVennDiagram(dat, theme = "kelly")

Shiny bindings for 'amVennDiagram'

Description

Output and render functions for using amVennDiagram within Shiny applications and interactive Rmd documents.

Usage

amVennDiagramOutput(outputId, width = "100%", height = "400px")

renderAmVennDiagram(expr, env = parent.frame(), quoted = FALSE)

Arguments

outputId

output variable to read from

width, height

a valid CSS dimension (like "100%", "400px", "auto") or a number, which will be coerced to a string and have "px" appended

expr

an expression that generates an amVennDiagram

env

the environment in which to evaluate expr

quoted

logical, whether expr is a quoted expression (with quote()); this is useful if you want to save an expression in a variable

Value

amVennDiagramOutput returns an output element that can be included in a Shiny UI definition, and renderAmVennDiagram returns a shiny.render.function object that can be included in a Shiny server definition.

Examples

if(require("shiny") && interactive()) {

library(amVennDiagram5)
library(shiny)

sets <- list(A = 1:20, B = 15:38, C = c(0:5, 20, 30:40))
diagram  <- makeVennData(sets)

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      radioButtons(
        "theme", label = "Theme",
        choices = c(
          "default",
          "dark",
          "dataviz",
          "frozen",
          "kelly",
          "material",
          "moonrise",
          "spirited"
        )
      )
    ),
    mainPanel(
      amVennDiagramOutput("diagram", height = "95vh")
    )
  )
)

server <- function(input, output, session) {

  output[["diagram"]] <- renderAmVennDiagram({
    amVennDiagram(
      diagram, theme = input[["theme"]]
    )
  })

}

shinyApp(ui, server)

}

Venn diagram data from a list of sets

Description

Make data for usage in amVennDiagram.

Usage

makeVennData(sets)

Arguments

sets

a named list of vectors representing some sets

Value

A list suitable for usage in amVennDiagram.

Examples

sets <- list(A = 1:20, B = 10:30, C = 15:35)
dat <- makeVennData(sets)
amVennDiagram(dat, theme = "spirited")