Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Although I don't think there is anything natively available in <code>shiny</code>, you can try adding <code>jQueryUI</code> to your application and using the Dialog widget. See <a href="http://jqueryui.com/dialog/" rel="noreferrer">http://jqueryui.com/dialog/</a>.</p> <p>(Un?)fortunately, you'll be forced to write some JavaScript to make it work.</p> <hr> <p>Per @GSee's suggestion, here's a very minimal example of what it takes to make it work.</p> <p>You'll need to download <a href="http://jqueryui.com/" rel="noreferrer">jQueryUI</a> and set up a shiny project with a structure like so:</p> <pre><code>. ├── server.R ├── ui.R └── www ├── css │ └── jquery-ui.css ├── images │ ├── animated-overlay.gif │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ ├── ui-bg_flat_75_ffffff_40x100.png │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ ├── ui-bg_glass_65_ffffff_1x400.png │ ├── ui-bg_glass_75_dadada_1x400.png │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ ├── ui-bg_glass_95_fef1ec_1x400.png │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png │ ├── ui-icons_222222_256x240.png │ ├── ui-icons_2e83ff_256x240.png │ ├── ui-icons_454545_256x240.png │ ├── ui-icons_888888_256x240.png │ └── ui-icons_cd0a0a_256x240.png └── js └── jquery-ui.js </code></pre> <p>(all of the image icons come part of jQueryUI)</p> <p>Next, add a file called <code>scripts.js</code> (or whatever you like) to the <code>www/js</code> folder, containing the following</p> <pre><code>$( function() { $("#dialog").dialog(); }) </code></pre> <p>This calls the <code>jQueryUI</code> <code>dialog</code> initializer on the element with id <code>dialog</code>.</p> <p>Next, have a <code>server.R</code> and <code>ui.R</code> as follows:</p> <pre><code>server.R -------- library(shiny) shinyServer( function(input, output, session) { ## a very unsafe, basic access to the R console output$dialog &lt;- renderPrint({ code &lt;- input$console output &lt;- eval( parse( text=code ) ) return(output) }) }) </code></pre> <p>and</p> <pre><code>ui.R ---- library(shiny) shinyUI(bootstrapPage( includeCSS("www/css/jquery-ui.css"), includeScript("www/js/jquery-ui.js"), includeScript("www/js/scripts.js"), textInput("console", "Enter an R Command"), uiOutput("dialog") )) </code></pre> <p>Now, if you do <code>runApp()</code>, you should see the results of evaluation of any code you write into the text input <code>console</code> appearing in the <code>dialog</code> box.</p> <p>Now, the question is, how can we minimize it, or only show it when, say, error code is produced? That I'll have to leave for you, because I think it'll be tricky. Some options:</p> <ol> <li><p>Figure out how to get our R code to send, or trigger, some JavaScript to show or hide the element. An example (not mine) using this to temporarily disable a button is <a href="https://gist.github.com/xiaodaigh/6810928" rel="noreferrer">here</a>.</p></li> <li><p>Attach a (JavaScript) observer or trigger to the output produced, and if you see an error (or output otherwise conforming in some way), show the box; otherwise hide it.</p></li> <li><p>Generate an actual Shiny input/output pair to handle behavior as desired. (Brief tutorial at <a href="http://rstudio.github.io/shiny/tutorial/#building-inputs" rel="noreferrer">http://rstudio.github.io/shiny/tutorial/#building-inputs</a>)</p></li> </ol> <p>If you want to get a bit more out of your jQueryUI dialog, you can also try the extension jQuery-dialogextend <a href="https://github.com/ROMB/jquery-dialogextend" rel="noreferrer">here</a>.</p> <p>And, disclaimer: the console here is only for demonstrative purposes; please don't put any shiny apps that run unsanitized code from the user into the wild!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload