2017-09-22 64 views
0

我試圖運行下面閃亮的應用程序,但我得到一個:錯誤:參數「mainPanel中」缺失,沒有默認設置

"ERROR: argument "mainPanel" is missing, with no default"

消息。即使我照顧sidebarLayout和sidebarPanel之外的mainPanel,並且我嘗試了另一種可用的網上相關解決方案,但錯誤仍然相同。

請幫我找到錯誤並糾正錯誤。

library(shiny) 

shinyUI(pageWithSidebar(
    titlePanel("Road Accident"), 
    sidebarLayout(

    sidebarPanel(selectInput('geo', 'Country', choices = list("Unknown" ="AT","BE","CZ","DE","DK","EL","ES","FI","FR", 
               "IE","IT","LI","LU","NL","PT","RO","SE","UK","PL","SI","BG","CH","CY", 
               "EE","HU","IS","LV","MT","NO","SK","HR","LT") 
          ) 
       ), 
    mainPanel(
     plotOutput("newHist")) 

) 
)) 


library(shiny) 
library(ggplot2) 
library(dplyr) 
library(eurostat) 

p1<-get_eurostat("tsdtr420",time_format="num") 
p2<-p1[!rowSums(is.na(p1)),] 

shinyServer(
    function(input, output) { 


    output$newHist<- renderPlot({ 
     p3 <- filter(p2, grepl(input$geo,geo)) 
    p<-ggplot(data=p3,aes(time,values))+geom_bar(stat="identity")+theme_bw()+theme(legend.position="none")+ 
     labs(title="Road Accidents",x="",y="Victims") 
     print(p) 

     output$geo 
    }) 
    }) 

回答

0

如果你這樣做沒有sidebarLayout,它工作正常。你只需要用?pageWithSidebar,?sidebarLayout等來檢查你所需的元素參數...... pageWithSidebar需要三個參數,你只給出兩個參數。

shinyUI(pageWithSidebar(
    titlePanel("Road Accident"), 
    sidebarPanel(selectInput('geo', 'Country', choices = list("Unknown" ="AT","BE","CZ","DE","DK","EL","ES","FI","FR", 
                   "IE","IT","LI","LU","NL","PT","RO","SE","UK","PL","SI","BG","CH","CY", 
                   "EE","HU","IS","LV","MT","NO","SK","HR","LT"))), 
    mainPanel(plotOutput("newHist"))) 
) 
相關問題