client/server interaction with shiny - part 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyServer( function(input, output, session) { | |
output$results <- renderPrint({ | |
input$mydata | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyUI( bootstrapPage( | |
# a div named mydiv | |
tags$div(id="mydiv", | |
style="width: 50px; height :50px; left: 100px; top: 100px; | |
background-color: gray; position: absolute"), | |
# an element for unformatted text | |
verbatimTextOutput("results"), | |
# javascript code to send data to shiny server | |
tags$script(' | |
document.getElementById("mydiv").onclick = function() { | |
var number = Math.random(); | |
Shiny.onInputChange("mydata", number); | |
}; | |
') | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment