【发布时间】:2020-03-31 12:37:24
【问题描述】:
这里有一个如何将国家标志添加到checkBoxGroupInput 的示例
https://gist.github.com/bborgesr/f2c865556af3b92e6991e1a34ced2a4a
我正在尝试使用来自 shinywidgets 的pickerinput 稍微调整代码以达到相同的结果。但是,在我的结果中,我没有看到任何图像。
library(shiny)
library(shinyWidgets)
countries <- c("Australia", "United Kingdom", "United States")
flags <- c(
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/au.svg",
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/gb.svg",
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/us.svg"
)
ui <- fluidPage(
pickerInput("countries", "countries", multiple = T,
choices = countries,
choicesOpt = list(content =
mapply(countries, flags, FUN = function(country, flagUrl) {
tagList(
tags$img(src=flagUrl, width=20, height=15),
country
)
}, SIMPLIFY = FALSE, USE.NAMES = FALSE)
))
,
textOutput("txt")
)
server <- function(input, output, session) {
output$txt <- renderText({
paste("You chose", paste(input$countries, collapse = ", "))
})
}
shinyApp(ui, server)
【问题讨论】: