Можно ли связать элемент selectInput с кнопкой действия открытия файла с помощью R shiny? Я хотел бы адаптировать аргумент кнопки действия onclick для этого.
Ниже приведен воспроизводимый пример:
Предположим, у нас есть «file_1.pdf» и «file_2.pdf» в папке «www», как я могу открыть файл, соответствующий выбору «Выбор ввода»?
library(shinydashboard)
library(shiny)
ui <- dashboardPage(
dashboardHeader(title = "Open file app"),
dashboardSidebar(),
dashboardBody(
fluidRow(
selectInput(inputId = "file_choice",label = "Choose the file to open",choices = c("file_1","file_2")),
actionButton("bell","Open the selected file", class = "btn action-button",onclick = "window.open('file_1.pdf')")) #onclick argument must be adapted
)
)
server <- function(input, output) {}
shinyApp(ui, server)
Большое спасибо!