Coder Social home page Coder Social logo

shiny_module's Introduction


title: "Shiny Module Learning" author: "Brian S Yandell" date: "May 19, 2016" output: html_document

This project is about learning how to use Shiny modules. I developed these as my modules were crashing, and I wanted to break down into simple steps. See links below for official resources.

The folder has several R scripts. Latest material is in the oldfaithful folder. See also Conference Material on Modules. These were adapted from and inspired by Garrett's talk. Each file is a complete shiny app that can be run.

  • simple.R simple Shiny script using sliderInput() and textOutput()
  • module.R simple.R modified to have key components in Shiny module
  • nested.R example nesting two modules
  • *_renderUI.R examples using renderUI() in server and uiOutput() in ui
  • *_observeEvent.R examples using observeEvent() for actionButton()
  • *_observe.R examples using observe() for checkboxInput()
  • *_renderUI_*.R examples using renderUI and observe() or observeEvent()

Key things to notice about namespace use for modules:

  • module UI and server must use same id
    • sliderTextUI("module") # in ui function
    • callModule(sliderText, "module", ...) # in server function
  • module server needs session as third argument
  • return argument from module server (if any) must be reactive()
  • module UI needs two nameserver components
    • ns <- NS(id) # to create namespace ID function
    • tagList( # tag list to wrap UI entries
    • sliderInput(ns("slider"), ...) # to use namespace ID
    • ) # ends tag list
  • module server has no special arrangements except in use of renderUI()
    • ns <- server$ns # to access namespace ID function
    • output$set_slider <- renderUI({
    • sliderInput(ns("slider"), ...) # to use namespace Id
    • })
  • module server has no special arrangements for update*Input
    • updateSliderInput(server, "slider", ...)
    • used in observe() and observeEvent()
  • conditionalPanel does not work as expected with modules

shiny_module's People

Contributors

kpatel427 avatar byandell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.