Learn R Programming

esquisse (version 0.1.7)

esquisserServer: Esquisse Shiny module

Description

Launch esquisse in a classic Shiny app.

Usage

esquisserServer(input, output, session, data = NULL,
  dataModule = c("GlobalEnv", "ImportFile"), sizeDataModule = "m")

esquisserUI(id, header = TRUE, choose_data = TRUE)

Arguments

input

standard shiny input

output

standard shiny output

session

standard shiny session

data

a reactiveValues with at least a slot data containing a data.frame to use in the module. And a slot name corresponding to the name of the data.frame.

dataModule

Data module to use, choose between "GlobalEnv" or "ImportFile".

sizeDataModule

Size for the modal window for selecting data.

id

Module's id.

header

Logical. Display or not esquisse header.

choose_data

Logical. Display or not the button to choose data.

Examples

Run this code
# NOT RUN {
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
  ),
  tags$div(
    style = "height: 700px;", # needs to be in fixed height container
    esquisserUI(
      id = "esquisse", 
      header = FALSE, # dont display gadget title
      choose_data = FALSE # dont display button to change data
    )
  )
)

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(
  tags$div( # needs to be in fixed height container
    style = "position: fixed; top: 0; bottom: 0; right: 0; left: 0;", 
    esquisserUI(id = "esquisse")
  )
)

server <- function(input, output, session) {
  
  callModule(module = esquisserServer, id = "esquisse")
  
}

shinyApp(ui, server)

}

# }

Run the code above in your browser using DataLab