library("shinypod")

cat_r_file <- function(file){
  cat("```R", readLines(file), "```", sep = "\n")  
}

cat_r_fn <- function(fn){
  cat("```R", capture.output(eval(fn)), "```", sep = "\n")  
}

In this vignette, we go into a little more detail of the structure of a shinypod.

Essentials

There are three essential functions for the UI. Let's consider the dygraph shinypod:

Convention

The functions dygraph_sidebar_side() and dygraph_sidebar_main() draw upon the elemental ui functions: dygraph_ui_input(), dygraph_ui_output() and dygraph_ui_misc().

Let's look at the code for dygraph_ui_input():

cat_r_fn(dygraph_ui_input)

We see that this returns a named tagList of HTML elements.

Note that we use the shinyjs::hidden() function to initally hide the inputs. We will use the server logic to show the controls when there is data available.

Similarly for dygraph_ui_output():

cat_r_fn(dygraph_ui_output)

This returns an empty tagList, but we keep the function for completeness.

Finally for dygraph_ui_misc():

cat_r_fn(dygraph_ui_misc)

Presentation layer

On top of the elemental layer, we make a presentation layer that consists of the functions:

Here's dygraph_sidebar_side():

cat_r_fn(dygraph_sidebar_side)

Here's dygraph_sidebar_main():

cat_r_fn(dygraph_sidebar_main)

These are the functions that you would use - in putting togther a shiny app, I would suggest using these presentation functions.



ijlyttle/shinypod documentation built on May 18, 2019, 3:41 a.m.