esquisse (version 0.1.7)

chooseData-module: Module for choosing data.frame

Description

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

Usage

chooseDataUI(id, label = "Choose data", icon = "database")

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

Arguments

id

Module's id.

label

Button's label.

icon

Button's icon.

input

Standard shiny input.

output

Standard shiny output.

session

Standard shiny session.

dataModule

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

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.

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 var 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