ggplot not generating correctly in shiny

i've omiited unnecessay parts of the app. App intended to visualise rainfall data

selectInput("area", "Select an area of choice" , choices = c(" Andaman.and.Nicobar.Islands"
,"Arunachal.Pradesh" , "Assam.and.Meghalaya" , "Naga.Mani.Mizo.Tripura",
"Himalayan.West.Bengal.and.Sikkim" , "Gangetic.West.Bengal" ),
selected = "Andaman.and.Nicobar.Islands") ,

mainPanel( plotOutput("timeseries") )

) # ui
server<-function(input, output){
output$timeseries<- renderPlot({
ggplot(file) + geom_line(aes(x=input$area, y=Time), color= "blue")
the dataset has a time coulmn, and then there are columns with region names containing rainfall values to the corresponding time.

Time Andaman and Nicobar Islands Arunachal Pradesh Assam and Meghalaya
1951 3275.1 3354.2 2613.8
1952 3079.9 2396.1 2851.3
1953 2721.9 2559.9
1954 3449 2859.1
1955 3349.6 5063.5 2761.2
1956 3080 4195.5 2802.9

#below is the image of plot

  1. In the choices you have your data with dots (" Andaman.and.Nicobar.Islands"), in the table not, make sure these are identical.
  2. You want to use the input variable as selector for the underlying data, not the name itself. It would be easier, to put the data into long format, call this column e.g. "region" and run a filtering based on the input, but it could be done on the fly as well:
selection = "hwy"  #store the variable we want to show

ggplot(mpg, aes(x = .data[[selection]],   # use the colum "hwy" as defined in selection
                y = cty)) +
  1. You probably want to put the year on the x-axis?

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.