r - 为 DT 输出渲染文本输入时出现 R 闪亮错误
问题描述
在我闪亮的应用程序中为 DT 渲染文本输入时,我遇到了一些非常奇怪的问题。textinput 存储一些值,用作应用程序的设置之一。这些设置存储在一个反应列表中,一个列表成员是一个 data.table - 存储所有渲染设置。
我做了一个可重现的例子,而不是代码片段。不漂亮,但它说明了。
library(shiny)
rv = reactiveValues()
ui <- shinyUI(fluidPage(
textInput(inputId = "textinput", label = h3("Numeric input"), value = "some value"),
tags$hr(),
fluidRow(column(3, verbatimTextOutput("textinput"))),
tags$hr(),
tabPanel("Settings table for viewing", dataTableOutput('settings_table')),
))
server <- function(input, output, session) {
observe({
# lst_names = list()
# lst_values = list()
rv$textinput <- renderText( input$textinput )
output$textinput <- renderText({ input$textinput }) # this is displayed nicely
# lst_names = c(lst_names, "rv$textinput")
# lst_values = c(lst_values, rv$textinput)
rv$settings = data.table(Var_names = "rv$textinput", Var_values = rv$textinput)
})
output$settings_table = DT::renderDataTable(options = list(pageLength = 50), {
rv$settings
})
}
shinyApp(ui, server)
我在 DT 的 github 中找到了这段文本,但我无法找到让它工作的方法。numericinput、rendertext、renderprint、将 rendertext/print 移出“观察”块也有同样的问题。
有什么建议么?
解决方案
你不使用好的dataTableOutput
。您必须使用DT::dataTableOutput
或,等效地,DT::DTOutput
.
library(shiny)
library(DT)
ui <- fluidPage(
textInput(inputId = "textinput", label = h3("Numeric input"),
value = "some value"),
tags$hr(),
fluidRow(column(3, verbatimTextOutput("textinput"))),
tags$hr(),
tabPanel("Settings table for viewing", DTOutput('settings_table')),
)
server <- function(input, output, session) {
output$textinput <- renderText({ input$textinput })
rv <- reactiveValues()
observe({
rv$textinput <- input$textinput
rv$settings <- data.frame(
Var_names = "rv$textinput",
Var_values = rv$textinput
)
})
output$settings_table <- renderDT(options = list(pageLength = 50), {
rv$settings
})
}
shinyApp(ui, server)
推荐阅读
- ios - 添加项目时出现 Xamarin IOS 链接器错误
- azure - 如果文件中不包含“azuremediaplayer.min.js”,Azure 媒体播放器将不起作用
- java - src.type() == CV_8UC1 断言在校正图像时失败
- sql - 是否可以使用 ANALYZE 表指令创建过程?
- excel - 在执行 Office 脚本操作中指定 Excel 文件时出现问题
- python - 如何在 Python 中打印一条语句以显示对 Pandas Dataframe 的数学运算结果?
- c# - Blazor 在提交表单数据之前执行逻辑
- sql - presto 将单列值拆分为多行
- html - 如何使 iframe 元素的高度与按钮元素的高度相同?
- python - 图像处理 w。云解决方案