使用 R Shiny,是否可以将 selectInput 项链接到打开文件操作按钮?我想调整动作按钮的 onclick 参数来实现它。
请在下面找到一个可复制的示例:
假设我们在“www”文件夹中有“file_1.pdf”和“file_2.pdf”,如何打开与选择输入选项对应的文件?
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)
非常感谢!