【发布时间】:2018-10-01 12:31:52
【问题描述】:
我一直在尝试为轻度、中度、重度和末期肾功能损害等不同选项创建一个闪亮的选择列表框。我想编写与选择选项之一的值一起使用的代码,其余的应该是 0。有人可以帮我吗? 另一件事是输入数据将用于一个名为 input$RI(肾损伤)的方程。 这是我尝试使用的代码:
在用户界面中:
fluidPage(
selectInput("RI",
"Renal Impairment:",
choices = list("Normal" = 1,
"Mild" = 2,
"Moderate + Severe" = 3,
"End Stage" = 4),
selected = 1),
hr(),
fluidRow(column(4, verbatimTextOutput("0")))
)
在服务器文件中:
function(input, output) {
output$RI <- renderPrint({ input$RI })
if (RI == 1) {
1 <- 0
2 <- 0
3 <- 0
4 <- 0
}
if (RI == 2) {
1 <- 0
2 <- 1
3 <- 0
4 <- 0
}
if (RI == 3) {
1 <- 0
2 <- 0
3 <- 1
4 <- 0
}
if (RI == 4) {
1 <- 0
2 <- 0
3 <- 0
4 <- 1
}
}
提前谢谢你。
【问题讨论】: