Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 我在Shiny中上传了一个.csv文件。我想读取列名并在selectInput中将其用作选项。我该怎么做?_R_Shiny_Bootstrap File Input - Fatal编程技术网

R 我在Shiny中上传了一个.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()在Shining App中上传了一个.csv文件。 我希望阅读列名并在selectInput()中将其显示为选项/选项。我该怎么做

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