The simplest way to include plots in your shinyApp is to use plotOutput
in the ui and renderPlot
in the server. This will work with base graphics as well as ggPlot
s
library(shiny)
library(ggplot2)
ui <- fluidPage(
plotOutput('myPlot'),
plotOutput('myGgPlot')
)
server <- function(input, output, session){
output$myPlot = renderPlot({
hist(rnorm(1000))
})
output$myGgPlot <- renderPlot({
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point()
})
}
shinyApp(ui, server)