R 我在Shiny中上传了一个.csv文件。我想读取列名并在selectInput中将其用作选项。我该怎么做?
我使用fileInput()在Shining App中上传了一个.csv文件。 我希望阅读列名并在selectInput()中将其显示为选项/选项。我该怎么做R 我在Shiny中上传了一个.csv文件。我想读取列名并在selectInput中将其用作选项。我该怎么做?,r,shiny,bootstrap-file-input,R,Shiny,Bootstrap File Input,我使用fileInput()在Shining App中上传了一个.csv文件。 我希望阅读列名并在selectInput()中将其显示为选项/选项。我该怎么做 fileInput("file1", "Choose CSV File", multiple = FALSE, accept = c("text/csv", "text/comma-separated-values,text/plai
fileInput("file1", "Choose CSV File",
multiple = FALSE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
我们还可以在ui部分的代码中使用服务器部分的变量吗?没有reprex,很难回答。但这是我的理论答案 如果需要列名,请添加
colnames()
ui.R
uiOutput("myselectinputUI")
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(''))
)
})
server.R
uiOutput("myselectinputUI")
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(''))
)
})
output$myselectinputUI