r - Shiny 中的列联表,可选择输入组或总值并验证输入
问题描述
我正在 Shiny 中建立一个列联表。我正在使用numericInput
和一些 CSS 来制作功能表,目前正在使用verbatimTextOutput
来提供行和列总计。
这可行,但我想做的是能够在任何框中输入数字(包括总数)并让它更正其余部分。因此,例如,可以将文本输入到结果正面和总计列中,然后自动将其填充到结果负面列中。我还没有找到一个很好的方法来让它与验证一起工作。任何帮助,将不胜感激。
(ui.r)
fluidRow(strong("Contingency Table")),
fluidRow(helptext("Input the ")),
fluidRow(column(width = 3),
column(h5("Outcome Positive"), width = 3),
column(h5("Outcome Negative"), width = 3),
column(h5("Total"), width = 3)),
fluidRow(column(h5("Intervention"), width = 3),
column(numericInput(inputId = "int_pos",
label = NULL,
value = 117,
min = 0),
width = 3),
column(numericInput(inputId = "int_neg",
label = NULL,
value = 138,
min = 0),
width = 3),
column(verbatimTextOutput("int_tot"),
width = 3)),
fluidRow(column(h5("Control"), width = 3),
column(numericInput(inputId = "con_pos",
label = NULL,
value = 109,
min = 0),
width = 3),
column(numericInput(inputId = "con_neg",
label = NULL,
value = 145,
min = 0),
width = 3),
column(verbatimTextOutput("con_tot"),
width = 3)),
fluidRow(column(h5("Total"), width = 3),
column(verbatimTextOutput("tot_pos"), width = 3),
column(verbatimTextOutput("tot_neg"), width = 3),
column(verbatimTextOutput("tot_tot"), width = 3))
),
server.R
output$int_tot = renderText({
input$int_neg + input$int_pos
})
output$con_tot = renderText({
input$con_neg + input$con_pos
})
output$tot_pos = renderText({
input$int_pos + input$con_pos
})
output$tot_neg= renderText({
input$int_neg + input$con_neg
})
output$tot_tot = renderText({
input$int_neg + input$con_neg + input$int_pos + input$con_pos
})
解决方案
推荐阅读
- java - 微服务 Java
- python - 使用 pandas 时如何查看股票代码
- python - Python:无法在寡妇上安装 scikit-learn(错误代码 1)
- gstreamer - 有没有办法在 Gstreamer 中区分双单声道和立体声?
- mule - Anypoint 监控 JVM Heap 和 Runtime manager vCore 是如何关联的?
- javascript - 使用蓝牙扫描仪时在 iPad 中显示完整的虚拟键盘
- android - 使用 Kotlin 实现 javaMail 中的多线程
- flutter - 在设计 Provider 设计以使应用程序颤动时遇到问题
- python - Python 正则表达式匹配开始和结束字符串,并且必须包含特定的单词
- python - 有没有更好的方法来比较基本真实值和预测值中的 nan 值?