Shiny not displaying my ggplot as I'd expect

后端 未结 3 1719
悲哀的现实
悲哀的现实 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:03

    In ggplot2 you can subset the overall data being passed to all layers (@GSee's answer) or, for indivdual layers you can use the subset argument to subset just for that layer. This may be useful if you are constructing more complex plots.

    Using the plyr function . is useful here for constructing the arguments

    # required in server.R (along with the other calls to library)
    library(plyr)
    
     p <- ggplot(finalDat, aes(y =Year, x = Value)) + 
            geom_point(subset = .(City ==input$city))
     print(p)
    

提交回复
热议问题