2013-06-09 5 views
0

나는 반짝이의 renerUI를 사용하여 this 질문의 지시에 따라 즉시 UI 객체를 만듭니다.반짝이는 동적 UI를 사용하여 객체 목록을 태그 목록으로 변환하는 중 오류가 발생했습니다

난 문제는이 라인을 this을 읽은 후

# Convert the list to a tagList 
do.call(tagList, plot_output_list) 

을 다음과 같은 오류

Error in if (!grepl(pattern, text)) return(text) : 
    argument is of length zero 

입니다 내가 아는 받고 있어요하지만 난 솔루션이 제안 정확히 무엇을하고 있어요. 도와 주시면 감사하겠습니다.

코드

Server.r

shinyServer(function(input, output) { 

    # Create an environment for storing data 
    symbol_env <- new.env() 

    output$plots <- renderUI({ 

     if (input$goButton == 0) 
      return() 

     if (loaded_index != input$chosen_index) { 

      # ... alot of code to generate data.frames and plots 

      output[["summary"]] <- renderPlot(grid.arrange(g1,g2,g3,g4,g5,nrow=1)) 

      for (i in 1:length(results)) { 
       # Need local so that each item gets its own number. Without it, the value 
       # of i in the renderPlot() will be the same across all instances, because 
       # of when the expression is evaluated. 
       local({ 
        my_i <- i 
        plotname <- object_name("plot", names(results[my_i])) 
         output[[plotname]] <- renderPlot({ 
          showme_plot(results[[names(results[my_i])]]$data , period = DEFAULT_TIME_PERIOD)}) 

        tablename <- object_name("table", names(results[my_i])) 
         output[[tablename]] <- renderTable({ 
          make_summary(names(results[my_i]))}) 
        }) 
      } 
     } 

     plot_output_list <- list() 

     # Graphical Summary  
     plot_output_list[["summary"]] <- tags$div(class="summary" , plotOutput("summary")) 

     # The List 
     for (symbol in names(results)) 
      plot_output_list[[symbol]] <- 
       tags$div(class = "container" , 
        tags$div(class = "name" , name(symbol)), 
        tags$div(class = "stats" , tableOutput(object_name("table", symbol))) , 
        tags$div(class = "plot" , plotOutput(object_name("plot", symbol), height = 530))) 

     print("Plot structure defined") 

     # Convert the list to a tagList 
     do.call(tagList, plot_output_list) 
    }) 
}) 

ui.r

require(shinyIncubator) 
shinyUI(
    bootstrapPage(
     tags$script(src = "keyboard_scroller.js") , 
     tags$link(rel="stylesheet" , type="text/css" , href="custom.css") , 
     actionButton("goButton", "Go!") , 
     selectInput("chosen_index" , "INDEX: " , list("A" = '1' , "B" = '2')) , 
     # This is the dynamic UI for the plots 
     uiOutput("plots") 
)) 

답변

0

나는 하나의 문제는 plot_output_list이 문자열에 의해 색인이되어서는 안된다는 추측 것, 숫자 대신 예 : plot_output_list[[symbol]] <- ...은이어야합니다.210

그래도 작동하지 않으면 오류가 발생한 직후 traceback()을 실행하여 오류가 발생한 위치를 확인할 수 있습니다.