我正在使用预测工具,并基于一些特征,我将计算风险预测。
由于它将成为一种全球性的工具,我希望人们可以选择以KG或LB来补充体重。
我试图在KG和LB之间进行switchInput切换,并且基于此开关,我希望无论是KG还是LB都显示一个liderInput(因此不能同时显示两者)。 (默认为KG)
我尝试使用ConditionalPanel,但是它不起作用。
有人可以提出一些可行的建议吗?
library(shiny)
library(shinyWidgets)
# Define UI ----
ui <- fluidPage(
titlePanel(title=div( "Risk prediction tool")),
p("Chronic Obstructive Pulmonary Disease (COPD) is a lung problem that can affect people mainly as they get older."),
selectInput("sex", label=p("What is your gender?"),
choices=list("Female"=1, "Male"=0), selected=1),
sliderInput("age", label=p("What is your age?"), min = 18, max = 90, value = 35),
strong("What is your weight?"),
br(),
switchInput("switchweight", value = TRUE , onLabel = "kg", offLabel = "lb"),
conditionalPanel(condition = "switchweight == TRUE",
sliderInput("weightKG", label=NULL, min = 25, max = 200, value = 75)),
conditionalPanel(condition = "switchweight == FALSE",
sliderInput("weightLB", label=NULL, min = 55, max = 440, value = 165))
)
# Define server logic ----
server <- function(input, output, session) {
}
# Run the app ----
shinyApp(ui = ui, server = server)