> downloadButton
function (outputId, label = "Download", class = NULL, ...)
{
aTag <- tags$a(id = outputId, class = paste("btn btn-default shiny-download-link",
class), href = "", target = "_blank", download = NA,
icon("download"), label, ...)
}
<bytecode: 0x000000001a919c58>
<environment: namespace:shiny>
Эта функция скрывается за кнопкой «Скачать». Просто используйте свою собственную функцию.
customDownloadbutton <- function(outputId, label = "Download"){
tags$a(id = outputId, class = "btn btn-default shiny-download-link", href = "",
target = "_blank", download = NA, icon("accessible-icon"), label)
}
Просто вставьте в icon
нужную иконку и используйте функцию, аналогичную обычной кнопке загрузки
Как это использовать:
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
customDownloadbutton <- function(outputId, label = "Download"){
tags$a(id = outputId, class = "btn btn-default shiny-download-link", href = "",
target = "_blank", download = NA, icon("accessible-icon"), label)
}
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
customDownloadbutton("myDownloadButton")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)