Not sure why my code shows all the countries' plots at the same time, I want to make it display only the country that's selected by the user. Does anyone know what went wrong with the code?
library(shiny)
require(readr)
countries <- read.csv("~/Desktop/share-deaths-suicide.csv")
# Define UI for application that draws a scatterplot
ui <- fluidPage(
  
  # Application title
  titlePanel("Country Data"),
  
  # Sidebar with a slider input for number of bins 
  sidebarLayout(
    sidebarPanel(
      selectInput("Entity",
                  "countries",
                  paste(countries$Entity), 
                  selected = "China", multiple = FALSE)
    ),
    
    # Show a plot of the generated distribution
    mainPanel(
      plotOutput("countryPlot")
    )
  )
)
# Define server logic required to draw a scatterplot
server <- function(input, output) {
  
  output$countryPlot <- renderPlot({
    country = input$Entity
    plot(countries$Year, countries$`Deaths...Self.harm...Sex..Both...Age..All.Ages..Percent`, col=ifelse(countries$Entity==country, "red","black"),
         main = "Sucide Rate of Countries", xlab = "Year", ylab = "Sucide rate",log="xy")
    options(scipen=999)
  })
}
# Run the application 
shinyApp(ui = ui, server = server)
 
    
 
    