r - 闪亮模块的两个问题
问题描述
这是一个最小的例子。我正在尝试模块化现有应用程序以分离不同的分析问题。每个问题都有一个用于输入的侧边栏面板和一个用于输出的主面板。我在为输入设置侧边栏面板时遇到两个问题。我将有两个按钮在第一个被选中后交换。此操作位于模块服务器代码中,需要读取所选分析(导航栏中的选项卡标签),然后对读取的值进行操作。我收到此问题的错误:警告:== 中的错误:比较 (1) 仅适用于原子和列表类型 44:[/appsdata/home/wk211a/Projects/vrat4/minexample.R#61] 1:runApp
第二个问题是我无法在第一个选项卡中显示简单的 renderText 消息。
这是代码:
##### Test Example
##### Setup VRAT App
ContCurrentSideBarPanelUI <- function(id){
ns <- NS(id)
tagList(
tabsetPanel(
id = "sbpcontin",
tabPanel(
"Setup",
value = "setup_Cont_Curr",
textOutput(ns("result"))
),
tabPanel(
"Verification",
value = "verify_Cont_Curr"
),
tabPanel(
"Process",
value = "process_Cont_Curr"
),
tabPanel(
"Design",
value = "req_Cont_Curr"
),
tabPanel(
"Risk Analysis",
value = "risk_Cont_Curr",
),
tabPanel(
"Guardbanding",
value = "gb_Cont_Curr"
),
tabPanel(
"Sampling",
value = "sample_Cont_Curr"
),
tabPanel(
"Decon",
value = "decon_Cont_Curr"
)
)
)
}
ContCurrentSideBarPanelServer <- function(id,appTabs,Maincount){
moduleServer(
id,
function(input,output,session){
observe({
output$result <- renderText({
paste0("Here I am ", 63)
})
})
observe({
if (appTabs == "cont_Data" ) {
showElement(id = "goButton")
hideElement(id = "goButton3")
}
})
x <- 93
return(x)
}
)
}
VRATui <- shinyUI(
### Start Navbar Page
navbarPage(
title = "Test Tool",
selected = "Introduction",
fluid=TRUE,
### Start App Tab panel
tabsetPanel(id = "appTabs",
type = "pills",
### Start the tab panel for the Data Screen
tabPanel(
value = "cont_Data",
title = "Continuous Data",
### Start the Continuous sidebar layout
sidebarLayout(
### Start the Continuous sidebar panel
sidebarPanel(
id = "cndsp",
width = 3,
style = "overflow-y:scroll; max-height: 80vh",
h4("Analysis of Current Data"),
hr(style="border-color: darkblue;"),
conditionalPanel(
condition = "input.appTabs == 'cont_Data' && input.Maincont == 'currentCont'",
### Submit setup for analysis
actionButton(inputId = "goButton", label = "Start Current Analysis", width = '100%'),
actionButton(inputId = "goButton3", label = "Update Current Analysis", width = '100%'),
### Sidebar Panel Tabs
ContCurrentSideBarPanelUI("ContCurrentSideBarPanel")
),
### End Continuous Data Analysis sidebar panel
),
mainPanel()
### End the sidebar layout
),
### End the Data tab panel
)
)
### End the app tabPanelSet
)
### End the navbarPage
)
VRATserver <- shinyServer(function(input, output, session) {
test <- ContCurrentSideBarPanelServer(id = "ContCurrentSideBarPanel",
reactive(input$appTabs),
Maincount = reactive(input$Maincount))
})
shinyApp(
ui = VRATui,
server = VRATserver
)
解决方案
结果很容易。我没有正确传递外部参数作为反应性参数。它应该是反应式({...})而不是反应式(...)。一旦更正,模块就会正确响应 appTabs() 并且 if 语句完成且没有错误。当这工作时,文本已正确输入到侧边栏选项卡中。
推荐阅读
- c# - C# WPF XAML - DataGrid 制作 2 列而不是 1
- python - 使用 Python 从具有独特标题打印技术(.inp 扩展名)的文件中解析标题字符串
- c# - C#登录系统,在将密码插入数据库之前需要帮助哈希密码
- javascript - 如何使用正则表达式解析 BBCode?
- tags - 计算应用程序中的 NFC 标签点击次数
- javascript - 按下链接后,Arduino Ethernet Shield Web 服务器强制刷新
- android - 如何通过在 FrameLayout 中添加视图来控制视图的位置?
- xslt - 以 xsl 参数为参数的 XSL 函数
- css - 背景图像需要一段时间才能加载到 wordpress divi 主题中
- sql - sql查询中表的NodeJS变量替换