I made a sub folder called WWW in the directory holding the app.R file and I put three image files there. The selectInput allows picking a variable name from the data frame and in each row there is an image associated with the variable name.
library(shiny)
require(shinydashboard)
DF <- data.frame(VarNames = c("Flower", "Car", "Boat"),
ImgLoc = c("WWW/Img1.jpg", "WWW/Img2.jpg", "WWW/Img3.jpg"),
stringsAsFactors = FALSE)
ui <- dashboardPage(title = "Title",
dashboardHeader(
title= "Title Data"
),
dashboardSidebar(
selectInput("VarName", "Variable", choices = DF$VarNames)
),
dashboardBody(
imageOutput("image1")
)
)
server <- function(input, output) {
output$image1 <- renderImage({
ImgTxt <- DF[DF$VarNames == input$VarName, 2]
width<- "80%"
height<- "20%"
list(src = ImgTxt,
contentType = "image/jpg",
width = width,
height = "auto"
)
}, deleteFile = FALSE)
}
shinyApp(ui, server)