2017-03-14 4 views
0

안녕하세요 내 반짝이는 앱 안에 문제가 있습니다. 응용 프로그램은 잘 작동하지만, 처음에 오류가 :반짝이는 응용 프로그램 렌더링 플롯에서 오류를 방지합니다.

Warning: Error in xy.coords: 'x' and 'y' lengths differ 
Stack trace (innermost first): 
    102: xy.coords 
    101: plot.default 
    100: plot 
    99: renderPlot [C:/Users/Stuhlian/Desktop/ghj.R#29] 
    89: <reactive:plotObj> 
    78: plotObj 
    77: origRenderFunc 
    76: output$plot1 
     1: runApp 

나는 단순위한 응용 프로그램의 다른 재료없이 오류를 재현하는 예제 코드를 만들어 :

ui <- fluidPage(
    mainPanel(uiOutput("samplematches"), 
       plotOutput("plot1") 

    ) 
    ) 

server <- function(input, output) { 
re1<-data.frame(x=c(1:10),y=c(1:10)) 
re2 <-data.frame(x=c(1:10),y=c(1:10)) 
re3<-data.frame(x=c(1:10),no.matches.Sample1=c(1:10),Sample2=c(11,9,8,4,5,4,3,2,6,2)) 
result <- reactive({list(re,re2,re3)}) 


output$samplematches <- renderUI({if(length(grep("Sample", colnames(result()[[3]])))>0){sliderInput("samplematches", "Select Sample for matched masses",min=1, max=length(grep("Sample", colnames(result()[[3]]))), value=1,step=1)} else{return()}}) 
output$plot1 <- renderPlot({plot(result()[[3]][,1], result()[[3]][,grep("Sample", colnames(result()[[3]]))[input$samplematches]]) }) 

} 

shinyApp(ui, server) 

아무도 알고 있나요을 이 오류를 방지하거나이 특수 오류의 출력을 숨기지 않으려면? 많은 감사합니다! renderUI 때까지 플롯의 평가를 지연

답변

2

사용 shiny::validate 완료하고 다시 서버로 값을 통과했다 :

ui <- fluidPage(
    mainPanel(uiOutput("samplematches"), 
      plotOutput("plot1") 

) 
) 

server <- function(input, output) { 
    re1<-data.frame(x=c(1:10),y=c(1:10)) 
    re2 <-data.frame(x=c(1:10),y=c(1:10)) 
    re3<-data.frame(x=c(1:10),no.matches.Sample1=c(1:10),Sample2=c(11,9,8,4,5,4,3,2,6,2)) 
    result <- reactive({list(re1,re2,re3)}) 


    output$samplematches <- renderUI({ 
    shiny::validate(
     need(length(grep("Sample", colnames(result()[[3]])))>0, "A message!") 
    ) 
     sliderInput("samplematches", "Select Sample for matched masses",min=1, max=length(grep("Sample", colnames(result()[[3]]))), value=1,step=1) 
    }) 

    output$plot1 <- renderPlot({ 
    shiny::validate(
     need(input$samplematches, "Input a value!") 
    ) 
    plot(result()[[3]][,1], result()[[3]][,grep("Sample", colnames(result()[[3]]))[input$samplematches]]) 
    }) 

} 

shinyApp(ui, server) 
+0

매우 도움이, 많은 감사를! – JmO

관련 문제