【发布时间】:2019-09-04 08:29:18
【问题描述】:
我正在尝试创建一个书籍目录,需要帮助在表格中的单元格中渲染图像。我正在使用的代码如下,我从闪亮应用程序的代码中获得的输出是一个带有列“图像”但在其单元格中包含图像的链接而不是图像。我该如何纠正这个问题?请帮助我 数据集中的 URL 格式如下:https://images.gr-assets.com/books/1447303603s/2767052.jpg
数据是这样的
title authors ratings_count average_rating image_url
HP JK 10 4 https://images.gr-assets.com/books/1447303603s/2767052.jpg
ui <- fluidPage(
####Heading##
titlePanel(div(HTML("<b> Interested In books? </b>"))),
###Creating tabs###
tabsetPanel(
####First tab for crime####
tabPanel(" Book Directory ",
sidebarLayout(
sidebarPanel(
#First Input##
selectizeInput(inputId = "Book",
label = " Choose a Book",
choices = book_names)),
##Output
mainPanel = (tableOutput("View")
)
)
)
)
)
###Server app
server <- function(input, output) {
output$View <- renderTable({
books1 <- books[books$title%in% input$Book,]
books1 %>%
mutate(image = paste0('<img src="', image_url, '"></img>')) %>%
select(image,title,authors,average_rating,ratings_count)
})
}
shinyApp(ui = ui, server = server)
【问题讨论】:
标签: r shiny shinydashboard shiny-server shiny-reactivity