Last active
March 30, 2021 11:32
-
-
Save ColinFay/4ff2721901c169703da049bce49bd5e2 to your computer and use it in GitHub Desktop.
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) | |
library(ggplot2) | |
ui <- function(request){ | |
tagList( | |
h2("Click on the plot to download it"), | |
plotOutput("plop") %>% | |
tagAppendAttributes( | |
onclick = 'var a = document.createElement("a"); a.href = $(this).find("img").attr("src"); a.download = "Image.png"; a.click(); ' | |
) | |
) | |
} | |
server <- function( | |
input, | |
output, | |
session | |
){ | |
output$plop <- renderPlot({ | |
ggplot(mtcars,aes(gear, carb)) + | |
geom_point() | |
}) | |
} | |
shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment