I have problems to understand this behavior:
I have a small shiny app organized in a package workflow like described here:
- Put all R code in the R/ directory.
- Write a function that starts your app (i.e. calls shinyApp() with your UI and server).
- Create a DESCRIPTION file in the root directory of your app.
Here is a minimal reproducible example:
library(shiny)
myApp <- function(...) {
ui <- fluidPage(
titlePanel("Minimal Shiny App"),
mainPanel(
div(
style = "display: flex; align-items: center;",
sliderInput("slider", "Slider", min = 1, max = 10, value = 5),
tags$img(src = "logo.png", width = 200, style = "margin-left: 20px;")
),
plotOutput("plot")
)
)
server <- function(input, output) {
output$plot <- renderPlot({
plot(1:input$slider, type = "l", lwd = 2)
})
}
shinyApp(ui = ui, server = server, ...)
}
myApp()
I would like to add the logo.png
image to the app:
1. Using this code, I get this:
library(devtools)
load_all()
myApp()
2. Using this code once, I get this:
runApp()
3. If I use now myApp()
(after I have used runApp() once in the app), I get this:
# After I used runApp() once before
myApp()
The logo.png
file is in www
folder in the R
folder.
All works fine if I do not use the package workflow. But I need this workflow and for me it is not possible to get the image there when using load_all()
and myApp()
.
I have used system.file
like tags$img(src = system.file("R/www", "logo.png", package = "test2"), width = 200, style = "margin-left: 20px;"))
but same behaviour