【发布时间】:2020-12-29 05:39:59
【问题描述】:
一个闪亮的应用小例子:
library(shiny)
library(tidyverse)
library(DT)
ui <- fluidPage(
# Application title
titlePanel("blah"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
DT::DTOutput('ex_table')
)
)
)
server <- function(input, output) {
output$ex_table <- DT::renderDataTable(mtcars %>% select(cyl) %>% mutate(blah = cyl + 2),
selection = 'none', editable = TRUE)
}
# Run the application
shinyApp(ui = ui, server = server)
由于我在renderDataTable() 中添加了editable = TRUE,因此您可以编辑单元格。
提供数据表的表有以下行:
mtcars %>% select(cyl) %>% mutate(blah = cyl + 2)
所以特征 'blah' 应该始终是 cyl + 2 中的任何内容。在屏幕截图中,我添加了 10,000,因此所需的输出将是数据表在按 Enter 后更新以显示 10,002。
这可能吗?我该怎么做?
【问题讨论】: