Skip to content

Instantly share code, notes, and snippets.

@yihui
Forked from jcheng5/server.R
Last active December 18, 2015 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yihui/5835366 to your computer and use it in GitHub Desktop.
Save yihui/5835366 to your computer and use it in GitHub Desktop.
xy = matrix(0.5, 1, 2)
shinyServer(function(input, output) {
output$myplot = renderPlot({
hover = input$myplot_hover
if (!is.null(hover))
xy <<- rbind(xy, c(hover$x, hover$y))
par(mar = rep(0, 4))
plot.new()
points(xy, pch = rep(c(21, 19), c(nrow(xy) - 1, 1)))
box()
})
})
shinyUI(basicPage(
plotOutput("myplot", hoverId="myplot_hover")
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment