下面的代碼在rhandsontable. 但是,我想將該影像與我存盤在計算機上的 jpg 影像交換。我嘗試修改以下內容as.character(img(src = "..."))以反映本地目錄和檔案名,但沒有成功。
有什么建議可以直接做到這一點嗎?
我搜索了解決方案,例如
代碼:
library(magrittr)
library(htmlwidgets)
library(rhandsontable)
library(shiny)
DF = data.frame(
Col_1 = c("Row 1"),
Col_Help = c(
as.character(img(
src = "https://images.plot.ly/language-icons/api-home/python-logo.png",
title = "My first help text",
style = "width: 50px;")
)
),
text = c("Row 1 does xxx"),
stringsAsFactors = FALSE
)
ui <- fluidPage(br(),rHandsontableOutput('my_table'))
server <- function(input, output, session) {
output$my_table <- renderRHandsontable({
rhandsontable::rhandsontable(
DF,
allowedTags = "<em><b><strong><a><big><img>"
) %>%
hot_cols(colWidths = c(200, 80)) %>%
hot_col(1:2, renderer = htmlwidgets::JS("safeHtmlRenderer")) %>%
hot_cols(colWidths = ifelse(names(DF) != "text", 100, 0.1))
})
}
shinyApp(ui, server)
uj5u.com熱心網友回復:
將您的檔案放在閃亮應用程式question_mark.jpg的www檔案夾中,然后DF按如下方式調整您的定義:
DF = data.frame(
Col_1 = c("Row 1"),
Col_Help = c(
as.character(img(
src = "question_mark.jpg",
title = "My first help text",
style = "width: 50px;")
)
),
text = c("Row 1 does xxx"),
stringsAsFactors = FALSE
)
輸出:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/520196.html
標籤:htmlr图片闪亮的
