this example code itself works fine, the plot appears on the app page. But when I run my code (which is structured similarly, it has a renderPlot which makes a call to a function that returns a ggplot), the plot shows up in a separate window.
What could be causing the plot to open in a separate popup window rather than render in the app? No ggplot options would cause this as far as I'm aware.
Hej,
i think its most likely your UI.
Just post a minimal shinyapp code ... like this:
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("example app"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
p('example Sidebar')
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("example")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
testPlot <- function() {
ggplot(data = mpg, mapping = aes(x = displ, y = hwy, color= drv)) +
geom_smooth(mapping = aes(linetype = drv), method = 'loess') +
geom_point()
}
output$example <- renderPlot({ testPlot() })
}
# Run the application
shinyApp(ui = ui, server = server)