Description Usage Arguments Details Value ShinyURL options Quick setup Author(s) Examples
Encode the state of Shiny app's widgets into an URL query string, and use parameters from the URL query string to initialize the app.
| 1 2 3 4 | shinyURL.server(session, options)
shinyURL.ui(display = TRUE, label = "Share URL", width = "100%",
  copyURL = TRUE, tinyURL = TRUE, ZeroClipboard.swf)
 | 
| session | Typically the same as the optional parameter passed into the 
Shiny server function as an argument; if missing defaults to 
 | 
| options | Named list of options | 
| display | logical, should the shinyURL widget be displayed | 
| label | Label for the URL field | 
| width | The width of the URL text field, e.g.  | 
| copyURL | Include a ‘Copy’ button for convenient copying to clipboard | 
| tinyURL | Use the TinyURL web service for shortening the URL | 
| ZeroClipboard.swf | URL of the file ZeroClipboard.swf, as passed to the ‘swfPath’ parameter of ‘ZeroClipboard.config’; if missing defaults to the local copy distributed with shinyURL | 
The shinyURL.server method contains server logic for encoding
and restoring the widgets' values. It is called from inside the app's 
server script, and can take the session objects as argument.
The argument options can contain a named list of options. These are
set by a call to options as ‘shinyURL.name’. See below for a list of available options.
The shinyURL.ui widget consists of a text field containing an
URL to the app's current view state.  By default it also features the 
convenience ‘Copy’ button for copying the URL to clipboard, and a 
‘TinyURL’ button for querying the URL shortening web service.  The 
inclusion of these buttons is optional and can be controlled by the 
copyURL and tinyURL arguments, respectively.
The ‘Copy’ feature uses the ZeroClipboard library, which provides an
easy way to copy text to the clipboard using an invisible Adobe Flash movie
and JavaScript. shinyURL includes the JavaScript code to your app 
automatically, but you also need to have the “ZeroClipboard.swf” 
available to the browser. By default shinyURL uses a local copy distributed
with the package; you can override this by setting the
ZeroClipboard.swf argument to shinyURL.ui, for example, use 
"//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.2.0/ZeroClipboard.swf"
for a file hosted on jsDelivr CDN.
shinyURL.server returns a reactive expression evaluating to 
the app's URL.
debug = TRUEPrint debug messages to the console
To start using shinyURL in your Shiny app, follow these three steps:
 Load the package in both 'server.R' an
ui.R': library("shinyURL") 
 Add a call to  
  shinyURL.server() inside the server function 
 Add the 
shinyURL.ui() widget to the user interface
Andrzej Oleś <andrzej.oles@embl.de>
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | if (interactive()) {
  library("shiny")
  
  ## A Simple Shiny App
   
  shinyApp(
    ui = fluidPage(
      titlePanel("Hello Shiny!"),
      sidebarLayout(
        sidebarPanel(
          sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30),
          shinyURL.ui()
        ),
        mainPanel(
          plotOutput("plot")
        )
      )
    ),
    server = function(input, output, session) {
      shinyURL.server(session)
      output$plot <- renderPlot({
        x <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)
        hist(x, breaks = bins, col = 'darkgray', border = 'white')
      })
    }
  )
  ## Shiny Widgets Demo
  shinyAppDir( system.file('examples', 'widgets', package='shinyURL') )
  ## Tabsets Demo
  shinyAppDir( system.file('examples', 'tabsets', package='shinyURL') )
  
  ## Showcase demo available live at https://gallery.shinyapps.io/shinyURL
  shinyAppDir( system.file('examples', 'showcase', package='shinyURL') )
  
  ## Interactive R Markdown document which uses a QR code to encode the URL
  if (require("rmarkdown") && require("qrcode"))
    run( system.file('examples', 'qrcode', 'qrcode.Rmd', package='shinyURL') )
    
  ## Use with dynamic user interface created by renderUI()
  shinyAppDir( system.file('examples', 'dynamicUI', package='shinyURL') )
}
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.