R/mod_tab_one.R

# Module UI
#' @title   mod_tab_oneui and mod_tab_one
#' @description  A shiny Module that ...
#'
#' @param id shiny id
#'
#' @export 
#' @importFrom shiny NS tagList 
#' @import datasets 
#' @examples 
mod_tab_oneui <- function(id){
  ns <- NS(id)
  tagList(
      # App title ----
      titlePanel("Miles Per Gallon"),
      
      # Sidebar layout with input and output definitions ----
      sidebarLayout(
          
          # Sidebar panel for inputs ----
          sidebarPanel(
              
              # Input: Selector for variable to plot against mpg ----
              selectInput("variable", "Variable:",
                          c("Cylinders" = "cyl",
                            "Transmission" = "am",
                            "Gears" = "gear")),
              
              # Input: Checkbox for whether outliers should be included ----
              checkboxInput("outliers", "Show outliers", TRUE)
              
          ),
          
          # Main panel for displaying outputs ----
          mainPanel(
              
              # Output: Formatted text for caption ----
              h3(textOutput("caption")),
              
              # Output: Plot of the requested variable against mpg ----
              plotOutput("mpgPlot")
              
          )
      )
  )
}
    
# Module server
#' mod_tab_one server function
#'
#' @param input internal
#' @param output internal
#' @param session internal
#'
#' @export
#' @rdname mod_tab_oneui
    
mod_tab_one <- function(input, output, session){
  ns <- session$ns
  
  # #server for tab 1 (not working when placed here)
  # formulaText <- reactive({
  #     paste("mpg ~", input$variable)
  # })
  # 
  # output$caption <- renderText({
  #     formulaText()
  # })
  # output$mpgPlot <- renderPlot({
  #     boxplot(as.formula(formulaText()),
  #             data = mpgData,
  #             outline = input$outliers,
  #             col = "#75AADB", pch = 19)
  # })
}
    
## To be copied in the UI
# mod_tab_oneui("tab_oneui_1")
    
## To be copied in the server
# callModule(mod_tab_one, "tab_oneui_1")
 
MartaGajewska/testGolemApp documentation built on May 11, 2019, 7:31 p.m.