2015-01-06 3 views
0

selectInput에 "1"및 "2"가 아닌 "Option1"및 "Option2"가 표시되기를 원합니다.R 프로젝트 반짝이 동적 목록 전송 문제

server.R

library(shiny) 
shinyServer(function(input, output) { 

## Uncomment one of the below options (single #) 

    ## This option works but the data.frame only has 1 level, mine has 20 levels 
    #my_list <- as.character(c("Option1","Option2")) 

    ## This option does not work and is as close as I can get to recreating my error 
    #my_list <- data.frame(c("Option1","Option2")) 

    ## This option does not work as ds has Factor w/ 20 levels, 20 obs. of 1 variable 
    #ds <- getData() 
    #ds <- data.frame(ds) 
    #my_list <- as.character(c(ds)) 


    output$my_list_select <- renderUI({ 
    selectInput(inputId = "select_input1", 
       label = h6("My List"), 
       choice = (my_list), 
       selected = 2) 
    }) 
}) 

ui.R

library(shiny) 
shinyUI(
    fluidPage(
    mainPanel(
     fluidRow(  
     column(4, 
       uiOutput("my_list_select") 
     ))))) 

에디션 : 그것은 가능한 한 재현 할 수 있도록 내가 위 다시 한 agstudy의 제안에 (I는 MYSQL이 로컬 데이터베이스에서 실행중인 쿼리는 getData()이므로 재현 할 수있는 대상은 제한적입니다.

감사합니다.

+0

'getData'는 요인을 반환합니다. 'my_list <- as.character (getData()) '를 시도하십시오. – agstudy

+0

예, 인자를 반환합니다. 'as.character()'를 사용하면 c (1, 2, ... 20)가 유일한 선택이됩니다. – ldr9007

+1

나는 당신의 요점을 모르겠다. 재현 할 수없는 예제없이 당신을 도울 수있는 매우 힘든 (시간 낭비). 제발,'as.character (getData())'의 결과를 질문에 추가하십시오. – agstudy

답변

관련 문제