2017-09-22 104 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"))) 
)