2016-11-21 46 views
0

我正在使用selectInput(....multiple=TRUE)創建用戶選擇的輸入列表,其中用戶可以選擇多個選項,但我無法檢查/閱讀用戶在我的server.R中選擇的選項。檢查閃亮服務器中的多個選擇

如果有人已經成功嘗試過,請分享一下嗎?

例如 - 對於目錄已如下因素文件 -

/User/DE/AvsB.de.txt- 

Feature.ID Read.Count.All Read.Count.A Read.Count.B FC 
ENSG00000121898 3367.375403 6734.750807 0 0 
ENSG00000104435 2161.235573 4322.471145 0 0 
ENSG00000229847 2111.660196 4223.320392 0 0 
ENSG00000046889 1302.993351 2605.986702 0 0 

/User/DE/CvsD.de.txt -

Feature.ID Read.Count.All Read.Count.C Read.Count.D FC 
ENSG00000248329 373.0309339 746.0618679 0 0 
ENSG00000144115 352.3786793 704.7573586 0 0 
ENSG00000158528 351.6252529 703.2505057 0 0 
ENSG00000189058 350.5375828 701.0751656 0 0 


library(gtools) 
D_files <- list.files(path = "/User/DE/",pattern = "*.de.txt" ,recursive = F, full.names = T) 
D_filename <- vector() 
for(i in 1:length(D_files)){ 
    D_filename[i] <- D_files[i] 
} 
D_filename <- unlist(strapplyc(D_filename, "/User/DE/(.*).de.txt")) 
names(D_files)<- D_filename 


    ui <- fluidPage(

    mainPanel(

     uiOutput("Quad_plot_comparison"), 
     HTML("<br><br>"), 
     br() 
) 
) 

    server <- function(input, output) { 
    output$Quad_plot_comparison <- renderUI({ 
     selectInput(inputId = "vars",label = h3("Select comparison"), choices = mixedsort(D_files), multiple = T) 
    }) 
    } 

    shinyApp(ui, server) 

我的代碼顯示在輸入文件名框,但我需要做以下

1- Select multiple file names from the box 
2- Read user input (variables in the input box) 
3- Read the files corresponding to these user input into a data frame 

我甚至不能獲得第二步t o工作,任何幫助都能奏效! 謝謝!

+0

這是絕對有可能,請張貼重複的例子 – HubertL

+0

@HubertL您好,感謝!我只是發佈我的代碼 – AnkP

+0

可重現的手段我不需要你的文件重現:請建立一個小的數據集,以便我可以很容易地重現你的問題(我只是想在R複製粘貼運行看到) – HubertL

回答

0

這是關於如何在selectInput中使用多選的小示例。你可以通過閱讀文件中的reactive使其適應你的場景:

library(shiny) 
shinyApp(ui=fluidPage(selectInput("select", "choose", c(1,2,3), multiple = TRUE), 
         textOutput("selected", inline=TRUE)), 
     server=function(input, output){ 
         selected <- reactive(ifelse(is.null(input$select), "nothing", 
                paste(input$select, collapse=","))) 
         output$selected <- renderText(paste("Selected=",selected())) 
         })