R flexdashboard: Pass column names from a file to selectinput for dropdown menu

Viewed 31

Please give your valuable comments.

I want to upload a metadata file in R flexdashboard and dynamically use the column names in the file as a list of elements in the dropdown menu. I am not able to make this possible using the dataframe in reactive mode. Many thanks in advance!

Code:

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
```

```{r}
  dataset <- eventReactive(input$file1,{
       dataset <- read.csv(input$file1$datapath, quote = "", check.names = FALSE, header = TRUE, sep = "\t")
     })
  
  meta_dataset <- eventReactive(input$file2,{
       meta_dataset <- read.csv(input$file2$datapath, quote = "", check.names = FALSE, header = TRUE, sep = "\t")
     })
  
```

## Column {.sidebar}

```{r}

fileInput("file1", "Choose Tab File",
                    multiple = TRUE,
                    accept = c("text/csv",
                             "text/comma-separated-values,text/plain",
                             ".csv"))

fileInput("file2", "Choose Metadata Tab File",
                    multiple = TRUE,
                    accept = c("text/csv",
                             "text/comma-separated-values,text/plain",
                             ".csv"))


selectInput("shape","Select a Column for Shape", choices = names(metadata))
```
0 Answers
Related