我已经使用fileInput((在Shiny App中上传了一个.csv文件。 我希望阅读列名并将它们显示为 selectInput(( 中的选项/选项。我该怎么做?
fileInput("file1", "Choose CSV File",
multiple = FALSE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
我们还可以在 ui 部分内代码的服务器部分使用变量吗?
没有 reprex 就不容易回答。但这是我理论上的答案。
如果需要列名,请添加colnames()
。
用户界面。R
uiOutput("myselectinputUI")
服务器。R
output$myselectinputUI <- renderUI({
list_label_value <- input$file1
# read my link with an other answer of mine below if you need many columns in the select input
setNames(list_label_value$value,list_label_value$label)
selectizeInput(inputId="myselectinput",
label="Report Choice",
choices = list_label_value,
width = '500px',
selected = "1"
# , options = list(render = I(''))
)
})
- 关于多列在选择中 在闪亮中选择输入: 具有许多列值 et 标签与垂直对齐