【发布时间】:2020-10-10 12:20:10
【问题描述】:
我是一个闪亮的新手,我可能有一个简单的问题,但我发誓我在这里花了半天时间阅读解决方案,找不到任何接近我需要的东西。 想象您有一个包含员工 ID、姓名、姓氏、年龄的数据库。 我需要在我的应用程序中有一个文本输入,允许用户输入 ID 并在同一行上查看姓名、姓氏和年龄。 我面临的问题是 textInput 将有一个标签(比如“ID”)。 我需要在同一行的所有其他三个字段都没有标签。 因此,我需要一种向三个 textOutput 元素添加标签或将它们显示为 textInput 的方法,该默认值必须在用户输入新 ID 后立即更改/表现得像输出一样。但是怎么做? 这是我的示例代码:
library(shiny)
u <- fluidPage(
titlePanel("Simple Selectable Reactive Function"),
sidebarLayout(
sidebarPanel(),
mainPanel(
h2("Results"),
fluidRow(column(2,
textInput("input_ID", label = "Cusip 1",
value = "123")),
column(2,
textOutput(outputId = "output_name")),
column(2,
textOutput(outputId = "output_lastname")),
column(2,
textOutput(outputId = "output_age"))
)
)
)
)
s <- function(input,output){
output$output_name <- renderText(
{ # here is where I will check in a database
paste("Sample Name")
})
output$output_lastname <- renderText(
{ # here is where I will check in a database
paste("Sample Last Name")
})
output$output_age <- renderText(
{ # here is where I will check in a database
paste("Sample Age")
})
}
shinyApp(ui=u,server=s)
也许我必须使用不同的小部件? 谢谢
【问题讨论】: