- 图片需要放在代 .R的相对路径,自己建个文件夹里面
- 代码
library(shiny)
# Define UI for app that draws a histogram ----
ui <- fluidPage(
# App title ----
titlePanel("Hello Shiny!"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
sliderInput(inputId = "bins",
label = "Number of bins:",
min = 1,
max = 5,
value = 3)
),
# Main panel for displaying outputs ----
mainPanel(
shiny::imageOutput(outputId = "tu")
)
)
)
# Define server logic required to draw a histogram ----
server <- function(input, output) {
output$tu <- renderImage({
filename <- normalizePath(file.path('pic/dx.png'))
# Return a list containing the filename
list(src = filename)
}, deleteFile = FALSE)
}
# Create Shiny app ----
shinyApp(ui = ui, server = server)