'Object 'input' not found and object 'output' not found in R Shiny App

I'm trying to create a scatter plot in Shiny App in R, but I keep getting the error messages that my input and output can not be found. I've tried all the things I could think of that could be causing these issues, but as of yet it is unresolved. I'd really appreciate some help. My code is the following:

My UI:

shinyUI(fluidPage(
  titlePanel("Scatterplot Basketball Statistics"),
    sidebarPanel(
      selectInput(inputId = "x", 
                    label = "Select variable to plot",
                      choices = names(dt.basketball),
                        selected = "Season"),
      selectInput(inputId = "y",
                    label = "Select variable to plot against",
                      choices = names(dt.basketball),
                        selected = "3PA"),
  #Output: Show the output of the scatter plot
  mainPanel(
    plotOutput(outputId = "scatterplot")
))
)
)

And my server:

library(ggplot2)
library(shiny)

shinyServer(function(input,output){
    output$scatterplot <- renderPlot({
    
    ggplot(data = dt.basketball, aes_string(input$x, input$y) + geom_point())
   
})
})

The error messages I get are the following:

Error in output$scatterplot <- renderPlot({ : object 'output' not found

and

Error in aes_string(input$x, input$y) : object 'input' not found


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source