Possible duplicate
Cannot populate drop down menu dynamically in R shiny
I have a small shiny app with some drop-down option for user. I created a subdirectory say data
inside shiny app containing csv files to appear in the drop-down menu. I used the below code, but i am not able to access the files in the data
subdirectory.
On ui.r:
filenames <- list.files(pattern="\\.csv")
selectInput(inputId="dataset",label= "Choose platform annotation file",filenames)
server.r:
dataInput <- reactive({
if (grepl("[/\\\\]", input$dataset)) {
stop("Invalid dataset")
}
read.csv(file.path("data", input$dataset))
})
output$annotation <- renderDataTable({
withProgress(message = 'Loading Data . . .', {
dataInput()
})
})
The above code allows me to access the csv files if they are inside the app as my server.r
and ui.r
is , not in the separate subdirectory inside shiny app.
I also want to know is this the correct way to access the data of above code, as i am not able to access the data further in my below code.
inputdata <- reactive({
df1 <- data.frame()
df1 <- dataInput()
if (is.null(df1))
return(NULL)
df1[] <- lapply(df1, as.character)
df1 <- df1[df1[,3]!='',]
df1 <- df1[!grepl('[/]', df1$Gene.Title),]
})
I tried this also
filenames <- list.files(pattern="\\.csv$data") ## data is my folder inside shiny app.
to access thedata
subdirectory inside shiny app with csv files, but not able to do.
Edited: Input file example
ID Gene Title Gene Symbol
1007_s_at discoidin domain receptor tyrosine kinase 1 DDR1
1053_at replication factor C (activator 1) 2, 40kDa 7-Mar
117_at heat shock 70kDa protein 6 (HSP70B') HSPA6
121_at paired box 8 PAX8
1255_g_at guanylate cyclase activator 1A (retina) GUCA1A
1294_at ubiquitin-like modifier activating enzyme 7 UBA7
1320_at protein tyrosine phosphatase, non-receptor PTPN21
1405_i_at chemokine (C-C motif) ligand 5 CCL5/CCL6
1431_at
1438_at EPH receptor B3 EPHB3
1487_at estrogen-related receptor alpha ESRRA
1494_f_at cytochrome P450, family 2 CYP2A6/CYP2