Learn R Programming

shinydlplot

Installation

remotes::install_github('alexvpickering/shinydlplot)

Usage

Example that renders a plotly with a download button to download the iris dataset:

library(shiny)
library(shinyjs)
library(shinydlplot)
library(plotly)

ui <- fluidPage(
  useShinyjs(),
  downloadablePlotlyUI(id = 'iris_plotly')
)

server <- function(input, output, session) {
  
  plot <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
  
  callModule(downloadablePlotly, 
             id = 'iris_plotly', 
             plot = plot, 
             filename = 'iris.csv', 
             content = function(file) {write.csv(iris, file)})
}

shinyApp(ui, server)

Example that renders a ggplot2 object with a download button to download the iris dataset:

library(shiny)
library(shinyjs)
library(shinydlplot)
library(ggplot2)

ui <- fluidPage(
  useShinyjs(),
  downloadablePlotUI(id = 'iris_plot')
)

server <- function(input, output, session) {

  plot <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point()

  callModule(downloadablePlot,
             id = 'iris_plot',
             plot = plot,
             filename = 'iris.csv',
             content = function(file) {write.csv(iris, file)})
}

shinyApp(ui, server)

Copy Link

Version

Install

install.packages('shinydlplot')

Monthly Downloads

234

Version

0.1.4

License

MIT + file LICENSE

Maintainer

Alex Pickering

Last Published

November 18th, 2022

Functions in shinydlplot (0.1.4)

downloadablePlotly

Server-side logic for plotly with download data button in modebar
hiddenDownloadUI

UI for hidden download link
downloadablePlotlyUI

UI for plotly with download data button in modebar
downloadablePlotUI

UI for plot with download data button
downloadablePlot

Server-side logic for plot with download data button
hiddenDownload

Logic for hidden download link