我有一个带有数据表的R Shiny应用程序.一列包含具有唯一ID的操作按钮.我想处理这些按钮的点击,但不幸的是,我的事件处理代码(一个简单的打印语句)永远不会被执行.看到这个自包含的例子(app.R
):
library(shiny)
library(DT)
ui <- shinyUI(
fluidPage(
title = "DataTable with Buttons",
fluidRow(
column(
width = 8,
dataTableOutput("employees")
)
)
)
)
server <- shinyServer(function(input, output) {
df <- data.frame(
name = c('Dilbert', 'Alice', 'Wally', 'Ashok', 'Dogbert'),
motivation = c(62, 73, 3, 99, 52),
stringsAsFactors = FALSE
)
fireButtons <- list()
fireButtonIds <- list()
for (r in rownames(df)) {
id <- paste("fire_", r, sep = "")
fireButtonIds[[r]] <- id
button <- actionButton(id, label = "Fire")
fireButtons[[r]] <- …
Run Code Online (Sandbox Code Playgroud)