ERRORS :Unused argument

I am trying to create an application with the shiny. My application was running well before but it's now producing this error below.

**ERROR: unused argument (mainPanel(plotOutput("myplot")))

MY CODE FOR THE ui.R FILE IS AS BELOW :

shiny server(
pageWithSidebar(
headerPanel("My First Shiny App"),

sidebarPanel( 
             selectInput("Distribution","Please select distribution Type",
                          choices = c("Normal","Exponential")),
             sliderInput("SampleSize","Please Select Sample Size: ",
                          min=100,max=5000,value=1000,step =100),
             conditionalPanel(condition = "input.Distribution == 'Normal'",
                              textInput("Mean","Please select the mean", 10)),
                              textInput("sd","Please select Standard Deviation", 3)),
             conditionalPanel(condition ="input.Distribution =='Exponential'",
                              textInput("lambda","Please select Exponential Lambda:",1))
             
),     
mainPanel(
  plotOutput("myplot")
)

)

FOR THE SERVER FILE CODE IS AS BELOW:

shinyServer(
function(input, output, session){

Output$myplot <-renderPlot({

 disType <- input$Distribution
 size <- input$SampleSize
 
 If(disType == "Normal"){
   
   randomVec <-rnorm(size, mean=as.numeric(input$mean),sd=as.numeric(input$sd))
 }
 else{
   
   randomVec <- rexp(size, rate= 1/ as.numeric(input$lambda))
 } 
 
 hist(randomVec, col="blue")

})
}

I changed a few things which I tried to document with comments. I adjusted the parentheses in the ui section and I fixed a few incidents of upper case and lower case letters being out of place.

library(shiny)

# Define UI for application that draws a histogram
ui <- pageWithSidebar(
  headerPanel("My First Shiny App"),
  
  sidebarPanel( 
    selectInput("Distribution","Please select distribution Type",
                choices = c("Normal","Exponential")),
    sliderInput("SampleSize","Please Select Sample Size: ",
                min=100,max=5000,value=1000,step =100),
    conditionalPanel(condition = "input.Distribution == 'Normal'",
                     textInput("Mean","Please select the mean", 10),#),
    textInput("sd","Please select Standard Deviation", 3)),
  conditionalPanel(condition ="input.Distribution =='Exponential'",
                   textInput("lambda","Please select Exponential Lambda:",1))
  
),     
mainPanel(
  plotOutput("myplot")
)
) # added )


# Define server logic required to draw a histogram
server <- function(input, output, session){
  
  output$myplot <-renderPlot({  #Was Output$myplot
    
    disType <- input$Distribution
    size <- input$SampleSize
    
    if(disType == "Normal"){ #was If(
      
      randomVec <-rnorm(size, mean=as.numeric(input$Mean),sd=as.numeric(input$sd)) # changed input$mean to input$Mean
    }
    else{
      
      randomVec <- rexp(size, rate= 1/ as.numeric(input$lambda))
    } 
    
    hist(randomVec, col="blue")
    
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

Thanks very much for you help.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.