library(shiny)
## Warning: package 'shiny' was built under R version 4.3.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
server <- shinyServer(
  function(input,output){
    output$myPlot <- renderPlot({
      selected_cars <- input$Cars
      sampled_data <- mtcars[mtcars$cyl == selected_cars,]
      sampled_data <- sampled_data[sample(nrow(sampled_data), input$sampleSize, replace = TRUE),]
      ggplot(sampled_data, aes(x = wt, y = mpg)) + geom_point(color = "darkblue") +
        labs(title = paste("Scatter Plot", selected_cars), x = "Weight",
             y = "Miles per Gallon")
    })
  }
)