Description Usage Arguments Value Examples
Use esquisse as a module in a Shiny application.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | esquisse_ui(
id,
header = TRUE,
container = esquisseContainer(),
controls = c("labs", "parameters", "appearance", "filters", "code"),
insert_code = FALSE
)
esquisse_server(
id,
data_rv = NULL,
default_aes = c("fill", "color", "size", "group", "facet"),
import_from = c("env", "file", "copypaste", "googlesheets")
)
esquisseContainer(width = "100%", height = "700px", fixed = FALSE)
|
id |
Module ID. |
header |
Logical. Display or not |
container |
Container in which display the addin,
default is to use |
controls |
Controls menu to be displayed. Use |
insert_code |
Logical, Display or not a button to insert the ggplot code in the current user script (work only in RStudio). |
data_rv |
A |
default_aes |
Default aesthetics to be used, can be a |
import_from |
From where to import data, argument passed
to |
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).
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | ### 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
),
checkboxGroupInput(
inputId = "aes",
label = "Aesthetics to use:",
choices = c(
"fill", "color", "size", "shape",
"weight", "group", "facet", "facet_row", "facet_col"
),
selected = c("fill", "color", "size", "facet"),
inline = TRUE
),
esquisse_ui(
id = "esquisse",
header = FALSE, # dont display gadget title
container = esquisseContainer(height = "700px")
)
)
server <- function(input, output, session) {
data_rv <- reactiveValues(data = iris, name = "iris")
observeEvent(input$data, {
if (input$data == "iris") {
data_rv$data <- iris
data_rv$name <- "iris"
} else {
data_rv$data <- mtcars
data_rv$name <- "mtcars"
}
})
esquisse_server(
id = "esquisse",
data_rv = data_rv,
default_aes = reactive(input$aes)
)
}
if (interactive())
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(
esquisse_ui(
id = "esquisse",
container = esquisseContainer(fixed = TRUE)
)
)
server <- function(input, output, session) {
esquisse_server(id = "esquisse")
}
if (interactive())
shinyApp(ui, server)
## You can also use a vector of margins for the fixed argument,
# useful if you have a navbar for example
library(shiny)
library(esquisse)
library(datamods)
ui <- navbarPage(
title = "My navbar app",
tabPanel(
title = "esquisse",
esquisse_ui(
id = "esquisse",
header = FALSE,
container = esquisseContainer(
fixed = c(55, 0, 0, 0)
)
)
)
)
server <- function(input, output, session) {
# lauch import data modal
import_modal(
id = "import-data",
from = c("env", "file", "copypaste"),
title = "Import data"
)
data_imported_r <- datamods::import_server("import-data")
data_rv <- reactiveValues(data = data.frame())
observeEvent(data_imported_r$data(), {
data_rv$data <- data_imported_r$data()
data_rv$name <- data_imported_r$name()
})
esquisse_server(id = "esquisse", data_rv = data_rv)
}
if (interactive())
shinyApp(ui, server)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.