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.
There are three essential functions for the UI. Let's consider the dygraph shinypod:
dygraph_ui_input() returns a named shiny::tagList of input elementsdygraph_ui_output() returns a named shiny::tagList of output elementsdygraph_ui_misc() returns a named shiny::tagList of miscellaneous elements, like help guides.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)
On top of the elemental layer, we make a presentation layer that consists of the functions:
dygraph_sidebar_side()dygraph_sidebar_main()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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.