2015-10-19 23 views
0

我嘗試做一個選擇菜單如下:變化selectizeInput選擇 - 錯誤的值在菜單

Interactively change the selectInput choices

的一切與一兩件事例外效果很好: 反而得到的值(如麥當勞),我得到的指數,雖然我沒有做任何不同(見下面的圖片鏈接)。哪裏可能是我的錯誤?

Picture

這裏我global.R:

partners<- read.csv("genes.csv", header=TRUE, fill=TRUE) 

server.R

shinyServer(function(input, output) { 

#subTable 
searchResult<- reactive({ 
subset(partners, grepl(input$nameSearch, partners$name)) 
}) 

output$searchResults <- renderTable({ 
searchResult()[,1] 
}) 


output$selectUI <- renderUI({ 
selectizeInput("partnerName", "Click in and select", choices=searchResult()[,1], multiple=TRUE) 
}) 
}) 

ui.R

library(shiny) 

shinyUI(pageWithSidebar(
# Give the page a title 
titlePanel("Tilte"), 

sidebarPanel(

textInput("nameSearch", "Search for name", "Blah"), 
htmlOutput("selectUI"), 
br(), 
submitButton("Update View"), 
br() 

), 
# Create a spot for the barplot 
mainPanel(
textOutput("text"), 
plotOutput("plot") 
) 
) 
) 

回答

0

我想你沒有得到指數,而是我一個因素的nteger表示。檢查課程partners[,1]。嘗試

output$selectUI <- renderUI({ 
    selectizeInput("partnerName", "Click in and select", 
        choices=as.character(searchResult()[,1]), multiple=TRUE) 
}) 

,當你閱讀的數據以及你可能添加stringsAsFactors=FALSE選項。

+0

非常感謝,那是問題並解決了問題!我是R新手,對這個因素不太熟悉 - 「問題」。我很高興你給了我小費! – Yosi

+0

沒問題,因素起初很混亂,它們被存儲爲整數以節省空間,每個整數都有一個標籤。 – jenesaisquoi