if (interactive()) {
library(shiny)
library(ggplot2)
library(periscope2)
shinyApp(ui = fluidPage(fluidRow(column(width = 12,
downloadablePlotUI("object_id1",
downloadtypes = c("png", "csv"),
download_hovertext = "Download plot and data",
height = "500px",
btn_halign = "left")))),
server = function(input, output) {
download_plot <- function() {
ggplot(data = mtcars, aes(x = wt, y = mpg)) +
geom_point(aes(color = cyl)) +
theme(legend.justification = c(1, 1),
legend.position = c(1, 1),
legend.title = element_blank()) +
ggtitle("GGPlot Example ") +
xlab("wt") +
ylab("mpg")
}
downloadablePlot(id = "object_id1",
logger = "",
filenameroot = "mydownload1",
downloadfxns = list(png = download_plot, csv = reactiveVal(mtcars)),
aspectratio = 1.33,
visibleplot = download_plot)
})
}
Run the code above in your browser using DataLab