esquisse (version 0.3.0)

module-chooseData: Module for choosing data.frame

Description

Module for choosing data.frame from user environment and select variable to use.

Usage

chooseDataUI(id, label = "Data", icon = "database", ...)

chooseDataServer( input, output, session, dataModule = c("GlobalEnv", "ImportFile"), data = NULL, name = NULL, selectVars = TRUE, selectedTypes = c("continuous", "discrete", "time"), coerceVars = FALSE, launchOnStart = TRUE, size = "m" )

Arguments

id

Module's id.

label

Button's label.

icon

Button's icon.

...

Arguments passed to actionButton

input, output, session

standards shiny server arguments.

dataModule

Data module to use, choose between "GlobalEnv" (select ad data.frame from Global environment) or "ImportFile" (import an external file supported by import).

data

A data.frame to use by default.

name

Character, object's name to use for data.

selectVars

Display module to select variables, TRUE by default.

selectedTypes

Type of variables selected by default in select variables module. Possible types are "discrete", "time", "continuous" and "id", by default "id" is discarded.

coerceVars

Display module to coerce variables between different class, TRUE by default.

launchOnStart

Opens modal window when the application starts.

size

Size for the modal window.

Value

a reactiveValues containing the data selected under slot data and the name of the selected data.frame under slot name.

Examples

Run this code
# NOT RUN {
if (interactive()) {
  
  library(shiny)
  library(esquisse)
  
  ui <- fluidPage(
    tags$h2("Choose data module"),
    fluidRow(
      column(
        width = 4,
        tags$h4("Default"),
        chooseDataUI(id = "choose1"),
        verbatimTextOutput(outputId = "res1")
      ),
      column(
        width = 4,
        tags$h4("No variable selection"),
        chooseDataUI(id = "choose2"),
        verbatimTextOutput(outputId = "res2")
      ),
      column(
        width = 4,
        tags$h4("Default data on start"),
        chooseDataUI(id = "choose3"),
        verbatimTextOutput(outputId = "res3")
      )
    )
  )
  
  server <- function(input, output, session) {
    
    res_dat1 <- callModule(
      chooseDataServer, id = "choose1",
      launchOnStart = FALSE
    )
    output$res1 <- renderPrint({
      str(reactiveValuesToList(res_dat1))
    })
    
    res_dat2 <- callModule(
      chooseDataServer, id = "choose2", selectVars = FALSE,
      launchOnStart = FALSE
    )
    output$res2 <- renderPrint({
      str(reactiveValuesToList(res_dat2))
    })
    
    res_dat3 <- callModule(
      chooseDataServer, id = "choose3", data = iris,
      launchOnStart = FALSE
    )
    output$res3 <- renderPrint({
      str(reactiveValuesToList(res_dat3))
    })
    
  }
  
  shinyApp(ui, server)
  
  
}
# }

Run the code above in your browser using DataLab