esquisse (version 0.1.2.900)

chooseData-module: Module for choosing data.frame

Description

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

Usage

chooseDataUI(id)

chooseDataServer(input, output, session, data = NULL, name = NULL, selectVars = TRUE, launchOnStart = TRUE, defaultData = NULL)

Arguments

id

Module's id.

input

standard shiny input.

output

standard shiny output.

session

standard shiny session.

data

a data.frame to use by default.

name

character, the name of data.

selectVars

logical, display menu to select vars to use in selected data.frame.

launchOnStart

launch modal when application is launched.

defaultData

a character vector of data.frames to choose along if there is no data.frames in Global environment. By default, data.frames from ggplot2 are used.

Value

a reactiveValues containing the data choosen 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