Input to Shiny app within URL

379 views
Skip to first unread message

MB

unread,
May 6, 2014, 7:09:58 PM5/6/14
to shiny-...@googlegroups.com

Hi,

I am interested in invoking a Shiny app through a JavaScript file, or, URL.

For example, I have an app where the user inputs x and the app computes x^2. The ui.R and server.R files are below:

library(shiny)
shinyUI(fluidPage(

  titlePanel("Shiny Text"),
  sidebarLayout(
    sidebarPanel(
      numericInput("x", "Value of x", 10)
    ),

    mainPanel(
      verbatimTextOutput("summary")
    )
  )
))


library(shiny)
shinyServer(function(input, output) {
  output$summary <- renderPrint({
      input$x^2
  })
})


Instead of using the Shiny UI, I would like to generate a URL of the generic form:    http://host.foo.com?x=5

which will produce the answer "25".

Is there a way to do this? What should the JavaScript file include?


I've been looking at the shiny.js file in the Firefox debugger, trying to understand (without success) how Shiny sends the request and receives a response. I've also looked at sites that describe how JavaScript can be embedded in Shiny, such as

http://shiny.rstudio.com/articles/dynamic-ui.html

http://ryouready.wordpress.com/2013/11/20/sending-data-from-client-to-server-and-back-using-shiny/

http://shiny.rstudio.com/articles/building-inputs.html


but these sources (if I understand correctly) always require that the app is run from R (using "runApp()").

I am a newbie in Shiny and web programming and any help is much appreciated.
Thanks!

Marina

unread,
May 7, 2014, 1:17:42 AM5/7/14
to shiny-...@googlegroups.com

Nick Meulemeester

unread,
May 12, 2014, 6:04:05 AM5/12/14
to shiny-...@googlegroups.com
this could be interesting for you.

Marina Bendersky

unread,
May 14, 2014, 5:13:44 PM5/14/14
to Nick Meulemeester, shiny-...@googlegroups.com
This is great!!

Thank you very much!


--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/qG7MUkCZMkA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages