R 如何在shiny中访问UI输入的精选名称?
我有一个单选按钮用户界面shinyApp。这些按钮是一个命名向量<代码>输入$radioInputs返回所选内容的值。如何访问名称,即获取输出R 如何在shiny中访问UI输入的精选名称?,r,shiny,R,Shiny,我有一个单选按钮用户界面shinyApp。这些按钮是一个命名向量输入$radioInputs返回所选内容的值。如何访问名称,即获取输出您选择的是a和值1 library(shiny) ui <- fluidPage( sidebarPanel( radioButtons(inputId = "radioInputs", label = "Choose radio inputs", choiceNames =
您选择的是a和值1
library(shiny)
ui <- fluidPage(
sidebarPanel(
radioButtons(inputId = "radioInputs",
label = "Choose radio inputs",
choiceNames = letters[1:3],
choiceValues = 1:3,
# choiceNames and choiceValues can be replaced with
# choices = c("a"=1, "b"=2, "c"=3)
selected = "a") ),
mainPanel(
textOutput("outputText")
)
)
server <- function(input, output) {
output$outputText <- renderText({
paste("Your choice is", input$radioInputs)
}
)
}
shinyApp(ui = ui, server = server)
库(闪亮)
ui替换outputext
的方法如下:
output$outputText <- renderText({
paste("Your choice is",
letters[as.numeric(input$radioInputs)],
"and the value",
input$radioInputs)
}
output$outputText显然只有当名称是字母时才有效。这里就是这种情况。那么,它回答了你的问题吗?也许这就是你想要的?