Description Usage Arguments Value Note Examples
Launch esquisse
in a classic Shiny app.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | esquisserServer(
input,
output,
session,
data = NULL,
dataModule = c("GlobalEnv", "ImportFile"),
sizeDataModule = "m"
)
esquisserUI(
id,
header = TRUE,
container = esquisseContainer(),
choose_data = TRUE,
insert_code = FALSE,
disable_filters = FALSE
)
esquisseContainer(width = "100%", height = "700px", fixed = FALSE)
|
input, output, session |
Standards |
data |
A |
dataModule |
Data module to use, choose between |
sizeDataModule |
Size for the modal window for selecting data. |
id |
Module's id. |
header |
Logical. Display or not |
container |
Container in which display the addin,
default is to use |
choose_data |
Logical. Display or not the button to choose data. |
insert_code |
Logical, Display or not a button to insert the ggplot code in the current user script (work only in RStudio). |
disable_filters |
Logical. Disable the menu allowing to filter data used. |
width, height |
The width and height of the container, e.g. |
fixed |
Use a fixed container, e.g. to use use esquisse full page.
If |
A reactiveValues
with 3 slots :
code_plot : code to generate plot.
code_filters : a list of length two with code to reproduce filters.
data : data.frame
used in plot (with filters applied).
For the module to display correctly, it is necessary to place it in a container with a fixed height. Since version >= 0.2.2, the container is added by default.
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | if (interactive()) {
### Part of a Shiny app ###
library(shiny)
library(esquisse)
ui <- fluidPage(
tags$h1("Use esquisse as a Shiny module"),
radioButtons(
inputId = "data",
label = "Data to use:",
choices = c("iris", "mtcars"),
inline = TRUE
),
esquisserUI(
id = "esquisse",
header = FALSE, # dont display gadget title
choose_data = FALSE, # dont display button to change data,
container = esquisseContainer(height = "700px")
)
)
server <- function(input, output, session) {
data_r <- reactiveValues(data = iris, name = "iris")
observeEvent(input$data, {
if (input$data == "iris") {
data_r$data <- iris
data_r$name <- "iris"
} else {
data_r$data <- mtcars
data_r$name <- "mtcars"
}
})
callModule(module = esquisserServer, id = "esquisse", data = data_r)
}
shinyApp(ui, server)
### Whole Shiny app ###
library(shiny)
library(esquisse)
# Load some datasets in app environment
my_data <- data.frame(
var1 = rnorm(100),
var2 = sample(letters[1:5], 100, TRUE)
)
ui <- fluidPage(
esquisserUI(
id = "esquisse",
container = esquisseContainer(fixed = TRUE)
)
)
server <- function(input, output, session) {
callModule(module = esquisserServer, id = "esquisse")
}
shinyApp(ui, server)
## You can also use a vector of margins for the fixed argument,
# useful if you have a navbar for example
ui <- navbarPage(
title = "My navbar app",
tabPanel(
title = "esquisse",
esquisserUI(
id = "esquisse",
header = FALSE,
container = esquisseContainer(
fixed = c(55, 0, 0, 0)
)
)
)
)
server <- function(input, output, session) {
callModule(module = esquisserServer, id = "esquisse")
}
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.