Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

shiny

I am trying to run the below Shiny App but I am getting a:

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

message. Even though I take care of the mainPanel inside the sidebarLayout and outside the sidebarPanel and I tried another relative solutions available on the web, but the error remains the same.

Please help me in finding the error and rectifying it.

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
    })
    })
like image 369
prishak Avatar asked Oct 17 '25 14:10

prishak


1 Answers

If you do it without sidebarLayout, it works fine. You just need to check the required arguments of your elements with ?pageWithSidebar, ?sidebarLayout and so on... pageWithSidebar requires three arguments, you were only giving two.

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")))
)
like image 91
shosaco Avatar answered Oct 20 '25 06:10

shosaco