r - (R/SHINY) - 使用 selectInput 选择要显示的(哪个)反应表
问题描述
所以我有一个简单的问题。
我有一个选择输入。让我们称它为 report_select,并带有“报告 1”和“报告 2”选项可供选择。
另外,我有一个 textInput (用于指定员工 ID)
我有两个反应器(我们称它们为 r_one 和 r_two)。这些导致基于员工的单独数据。
我有一个输出 $table1
目标:我希望下拉菜单控制两个反应性报告中的哪一个显示在表 1 中。
注 1:表格单独工作正常。我可以毫无问题地一个接一个地显示。注 2:我使用 SHINY 以及 tabsetpanel 和 tabpanel 进行组织
有什么方法可以帮助解决这个问题吗?
方法 1:(错误是“不允许从 shionyoutput 对象读取对象)
library(shiny)
library(readxl)
library(dplyr)
library(tidyr)
# Globally Pull In Files
new_compdump_data <- read_xlsx("C:/temp/FILE.xlsx")
#Format Imported Data
clean_new <- subset(new_compdump_data,is.na(new_compdump_data$Term_Date))
clean_new$AIN <- as.numeric(clean_new$AIN)
clean_new$`MIP value` <- clean_new$`MIP%`*clean_new$Salary
# Begin UI
ui <- fluidPage(
titlePanel("Data Tool"),
sidebarLayout(
sidebarPanel(
selectInput(inputId = "report_select",
label = "Select a Report",
choices = c("Base Info","Stock Info")),
textInput("stock_ain","AIN")
), #End SideBarPanel
mainPanel(
tabsetPanel(
tabPanel(title="Base Info",tableOutput("table1")
)))
))
#======= SHINY - Server Section
server <- function(input, output) {
report1 <- reactive({
subset(clean_new[c(5,1,2,3)],clean_new$AIN==input$AIN)
})
report2 <- reactive({
subset(clean_new[c(5,6,7,8)],clean_new$AIN==input$AIN)
})
report_choose <- reactive({
ifelse(input$report_select=="Base Info",report1(),
ifelse(input$report_select=="Stock Info",report2()))
})
output$table1({
report_choose()
})
} #End server info
# Run the App
shinyApp(ui = ui, server = server)
方法2:错误:同上
与上面相同,但对 report_choose 的反应是:
report_choose <- reactive{(
switch(input$report_select,
"Base Info"=report1(),
"Stock Info"=report2())
)}
方法 3:(错误是“不允许从 shionyoutput 对象读取对象)
与上述相同(部分),但
report_choose <- reactive({
if(input$report_select=="Base Info") {
report1()
} else {
report2()
}
})
还是没有骰子。有什么想法或方法吗?
解决方案
推荐阅读
- sql - 当其中的所有值都是 VarChar 值时,DECODE 如何知道要评估什么?
- java - Mongotemplate 更新更改文档结构
- python - 通过 USB 将存储从 android 复制到 PC 以从 android 恢复已删除的照片
- dataframe - 在大数据上将 group_by 系列连接成一个
- acumatica - Acumatica REST API - 成功接收 200 次调用时,响应正文为空。这只会间歇性发生
- python - 我应该如何将 Web 应用程序部署到 Debian?
- ballerina - 来自http请求的不完美json返回字符串
- tensorflow - 对象检测模型在相机帧上表现不佳
- python - discord py - 自定义命令前缀不起作用(没有命令运行)
- javascript - 命名导出的下一个 JS 动态导入