2016-11-21 48 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())) 
         })