如何在限制 conditionalPanel() 的可访问性的同时保持可见性?
How to keep visibility while restricting the accessibility of conditionalPanel()?
我有一个conditionalPanel()
。我正在寻找一种解决方案,使 conditionalPanel()
保持可见,但如果不满足条件则无法访问。
条件是当input$n_sygdom >= 1
,然后show/activateinput$ecs
和input$contra.pos
.
我目前有
配合剧本
library(shiny)
library(survminer)
ui <- fluidPage(
titlePanel("Survival Curve of individualized pN-staging\n"),
br(),
fluidRow(
column(3,
wellPanel(style = "height:150px", sliderInput("n_fjernet", "Lymph Nodal Yield", min = 2, max = 120, value = 40))
),
column(3,
wellPanel(style = "height:150px", sliderInput("n_sygdom", "Number of positive lymph nodes", min = 0, max = 40, value = 0))
),
column(3,
wellPanel(style = "height:150px", conditionalPanel(
condition = "input.n_sygdom >= 1",
radioButtons("ecs", "Extracapsular extension", c("No","Yes"))))
),
column(3,
wellPanel(style = "height:150px", conditionalPanel(
condition = "input.n_sygdom >= 1",
radioButtons("contra.pos", "Neck involvement", c("Contra.","Ipsi."))))
)
),
br(),
#Row of Outputs (make sure the columns sum to 12)
fluidRow(
column(12, align="center"
),
column(12, align="center")
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
我不喜欢 input$ecs
和 input$contra.pos
在 input$n_sygdom==0
时只是两个灰色框。
我正在寻找一种解决方案,使 input$ecs
和 input$contra.pos
在 input$n_sygdom==0
时可见但无法访问。
像这样 input$n_sygdom==0
:
像这样 input$n_sygdom >= 1
这里是shinyjs::disable
的处理方法:
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
titlePanel("Survival Curve of individualized pN-staging\n"),
br(),
fluidRow(
column(
3,
wellPanel(
style = "height:150px",
sliderInput("n_fjernet", "Lymph Nodal Yield",
min = 2, max = 120, value = 40)
)
),
column(
3,
wellPanel(
style = "height:150px",
sliderInput("n_sygdom", "Number of positive lymph nodes",
min = 0, max = 40, value = 0)
)
),
column(
3,
wellPanel(
style = "height:150px",
radioButtons("ecs", "Extracapsular extension", c("No","Yes"))
)
),
column(
3,
wellPanel(
style = "height:150px",
radioButtons("contra_pos", "Neck involvement", c("Contra.","Ipsi."))
)
)
)
)
server <- function(input, output, session) {
observeEvent(input[["n_sygdom"]], {
if(input[["n_sygdom"]] < 1){
disable("ecs")
disable("contra_pos")
}else{
enable("ecs")
enable("contra_pos")
}
})
}
shinyApp(ui, server)
我有一个conditionalPanel()
。我正在寻找一种解决方案,使 conditionalPanel()
保持可见,但如果不满足条件则无法访问。
条件是当input$n_sygdom >= 1
,然后show/activateinput$ecs
和input$contra.pos
.
我目前有
配合剧本
library(shiny)
library(survminer)
ui <- fluidPage(
titlePanel("Survival Curve of individualized pN-staging\n"),
br(),
fluidRow(
column(3,
wellPanel(style = "height:150px", sliderInput("n_fjernet", "Lymph Nodal Yield", min = 2, max = 120, value = 40))
),
column(3,
wellPanel(style = "height:150px", sliderInput("n_sygdom", "Number of positive lymph nodes", min = 0, max = 40, value = 0))
),
column(3,
wellPanel(style = "height:150px", conditionalPanel(
condition = "input.n_sygdom >= 1",
radioButtons("ecs", "Extracapsular extension", c("No","Yes"))))
),
column(3,
wellPanel(style = "height:150px", conditionalPanel(
condition = "input.n_sygdom >= 1",
radioButtons("contra.pos", "Neck involvement", c("Contra.","Ipsi."))))
)
),
br(),
#Row of Outputs (make sure the columns sum to 12)
fluidRow(
column(12, align="center"
),
column(12, align="center")
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
我不喜欢 input$ecs
和 input$contra.pos
在 input$n_sygdom==0
时只是两个灰色框。
我正在寻找一种解决方案,使 input$ecs
和 input$contra.pos
在 input$n_sygdom==0
时可见但无法访问。
像这样 input$n_sygdom==0
:
像这样 input$n_sygdom >= 1
这里是shinyjs::disable
的处理方法:
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
titlePanel("Survival Curve of individualized pN-staging\n"),
br(),
fluidRow(
column(
3,
wellPanel(
style = "height:150px",
sliderInput("n_fjernet", "Lymph Nodal Yield",
min = 2, max = 120, value = 40)
)
),
column(
3,
wellPanel(
style = "height:150px",
sliderInput("n_sygdom", "Number of positive lymph nodes",
min = 0, max = 40, value = 0)
)
),
column(
3,
wellPanel(
style = "height:150px",
radioButtons("ecs", "Extracapsular extension", c("No","Yes"))
)
),
column(
3,
wellPanel(
style = "height:150px",
radioButtons("contra_pos", "Neck involvement", c("Contra.","Ipsi."))
)
)
)
)
server <- function(input, output, session) {
observeEvent(input[["n_sygdom"]], {
if(input[["n_sygdom"]] < 1){
disable("ecs")
disable("contra_pos")
}else{
enable("ecs")
enable("contra_pos")
}
})
}
shinyApp(ui, server)