I am trying to plot a line using geom_line from the ggplot package. This line should be interactive and is dependent on the selected state and macro variable over a selected time series. While the majority of it seems to run fine, I cannot seem to get geom_line() to plot anything.
I have tried grouping the data, as well as using the as.numeric() function for the 'year' variable, but nothing seems to work.
Server:
server <- function(input, output){
  output$plot1 <- renderPlot({
 ggplot(data = filter(c1, state == input$state1), 
        aes_string(x = as.numeric("year"), y = input$macroVar, group = 1)) +
   geom_line() +
   scale_x_continuous(limits = input$years) +
   labs(title = paste(col_alias(input$state1)),
        x = paste("Year"),
        y = paste(col_alias2(input$macroVar))) +
        theme_bw()})
  output$plot2 <- renderPlot({
ggplot(data = filter(c1, state == input$state2),  
       aes_string(x = as.numeric("year"), y = input$macroVar, group = 1)) +
  geom_line() +
  scale_x_continuous(limits = input$years) +
  labs(title = paste(col_alias(input$state2)),
       x = paste("Year"),
       y = paste(col_alias2(input$macroVar))) +
      theme_bw() })  
}   
shinyApp(ui = ui, server = server)
 
    