Shiny not displaying my ggplot as I'd expect

后端 未结 3 1720
悲哀的现实
悲哀的现实 2021-01-11 15:39

What\'s keeping my little Shiny app from displaying my ggplot? When I replace the code in renderPlot() with an example using the base plot function it comes together. I\'m

3条回答
  •  醉话见心
    2021-01-11 16:25

    There are two issues here.

    First, you shouldn't subset in aes -- it expects column names. Instead, subset the data.frame that you provide to ggplot (thanks to @Roland from R chat)

    Second, you must explicitly print your ggplot object in your shiny app.

    Try this:

    p <- ggplot(finalDat[finalDat$City == input$city,], aes(x = Year, y = Value))
    p <- p + geom_point()
    print(p)
    

提交回复
热议问题