Easily add help documentation to shiny elements, using markdown files.
The advantages of using this package are:
shinyhelper 0.3.1 now on CRAN! Go to: https://cran.r-project.org/package=shinyhelper You can install the package with:
To get the latest development version, you can use the
devtools package to install from GitHub directly:
In both cases, then load the package in with:
Alternatively, run the demo locally with:
You can add help files to any shiny element, including all inputs and outputs, with a simple call to
# load the package library(shinyhelper) ... # For elements in your ui you wish to add a help icon to helper(plotOutput(outputId = "plot")) # if you have %>% loaded, you can do plotOutput(outputId = "plot") %>% helper() ... # In your server script, include: observe_helpers() # this triggers the modal dialogs when the user clicks an icon # specify the name of your directory of help markdown files here # e.g. observe_helpers(help_dir = "help_mds") will look for a directory called help_mds # If you wish to include mathematical formulae in your markdown, use the `withMathJax` argument: # observe_helpers(withMathJax = TRUE)
Note that as of shinyhelper v0.3.1, you can define
helpers in dynamic UI elements as well! This opens up the option to display different helpfiles depending on current input settings, improving user experience. Thanks to those who flagged this issue and waited patiently for a fix!
All you need now is some content for your help page. You can specify this in 2 ways:
To specify inline content, simply set
type = "inline" in
helper, and supply the
content can be a character vector, in which case each element will be a new line. You can also use raw HTML tags to format your inline content E.g.
plotOutput(outputId = "plot") %>% helper(type = "inline", title = "Plot", content = c("This is a <b>plot</b>.", "This is on a new line."))
To use markdown, set
type = "markdown" in
helper, and supply the name of your markdown file (without the .md) in the
content argument. This file should be in the directory specified by the
help_dir argument to
plotOutput(outputId = "plot") %>% helper(type = "markdown", content = "Plot") # this will search for 'Plot.md' in the directory given in observe_helpers
You can specify a
title argument too, or leave it blank and use a
## Heading in your markdown document.
You can change the type of icon used and its colour, as well as passing CSS inline.
The icons are
shiny::icon("question-circle") icons by default, but you can change them individually using the
icon argument of
plotOutput(outputId = "plot") %>% helper(icon = "exclamation")
Please see Font Awesome for the available icons.
You can change the icon colour with the
colour argument. Pass it any valid CSS colour as a character string.
plotOutput(outputId = "plot") %>% helper(colour = "green")
You can pass a
style argument to modify CSS inline. This applies to the
<div> containing the icon.
plotOutput(outputId = "plot") %>% helper(style = "color: red;")
Note: Passing a colour in a
style argument will override
By default, all help files are medium sized
modalDialog() boxes (
size = "m"). You can change each one though, by passing the
size argument to
plotOutput(outputId = "plot") %>% helper(size = "l")
There is also a function,
create_help_files() to quickly create a directory of help files from a vector of names.
# Run this interactively, not in a shiny app create_help_files(files = c("Clusters", "Columns", "PlotHelp"), help_dir = "helpfiles")
help_dir will be "helpfiles" by default.
Obviously, this package would not be possible (or indeed meaningful) without the incredible shiny package. Full credit to the authors of shiny for doing all of the actual work!
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.