Description Usage Arguments Value Examples
Output and render functions for using d3Venn within Shiny applications and interactive RMD documents
1 2 3 | d3VennOutput(outputId, width = "100%", height = "400px")
renderD3Venn(expr, env = parent.frame(), quoted = FALSE)
|
outputId |
string, output variable to read the d3Venn diagram from |
width, height |
Must be a valid CSS unit (like “ |
expr |
expression, which creates the d3Venn object. |
env |
environment in which to evaluate |
quoted |
boolean, is |
An output element for use in UI.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | if (requireNamespace("shiny", quietly = TRUE) && interactive()) {
library(shiny)
options(device.ask.default = FALSE)
ui <- fluidPage(
titlePanel("Venn Diagram"),
sidebarLayout(
sidebarPanel(
sliderInput("a", "Set A:", 10, 100, 10, 10),
sliderInput("b", "Set B:", 10, 100, 10, 10),
sliderInput("ovl", "Overlap:", 0, 100, 10, 10, post = "%")
),
mainPanel(
d3VennOutput("venn")
)
)
)
server <- function(input, output) {
output$venn <- renderD3Venn({
n_A <- req(input$a)
n_B <- req(input$b)
n_AB <- round(req(input$ovl) / 100 * min(n_A, n_B))
if (n_AB > 0) {
dat <- data.frame(sets = I(list("A", "B", list("A", "B"))),
size = c(n_A, n_B, n_AB))
} else {
dat <- data.frame(sets = c("A", "B"),
size = c(n_A, n_B))
}
d3Venn(dat)
})
}
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.