我试图将HTML包含在闪亮的textInput()
函数中。更具体地说,我想在窗口小部件中显示的文本旁边包含一个图像。以下内容写于ui.R
:
shinyUI(navbarPage("Page Title",theme = shinytheme("united"),
tabPanel("Panel title",
sidebarLayout(
sidebarPanel(
textInput("textInputObject", c("Input Header", tags$span(HTML("<img src='http://www2.psd100.com/ppp/2013/10/0401/Blue-question-mark-icon-1004195336.png', title='help', alt='' />"))), value = "put text here"),
checkboxGroupInput("checkbInp", "Checkbox Header",
c("Checkbox1 [?]" = "check1" ,
"Checkbox2 [?]" = "check2" ,
"Checkbox3 [?]" = "check3") ,
selected = c("check1"))
)
)
这给了我:
我能够将图片包含在textInput
的标题中。但是,它只应显示&#34;输入标题&#34;然后是图像。如图所示,&#34; span&#34;来自tags$span
的信息也会显示出来。我该如何解决这个问题?
我不知道如何将图片包含在checkboxGroupInput
中。它应该取代&#34; [?]&#34; (见图)
谢谢!
答案 0 :(得分:2)
#1 您可以在list
来电之前使用HTML
轻松解决此问题。对于#2 有点棘手,因为您可能需要自己编写整个checkbox
。也许你可以像我一样宣布单独的那些,那会没关系吗?
rm(list = ls())
library(shiny)
library(shinythemes)
ui <- navbarPage("Page Title",theme = shinytheme("united"),
tabPanel("Panel title",
sidebarLayout(
sidebarPanel(
textInput("textInputObject",
c("Input Header",list(HTML("<img src='http://www2.psd100.com/ppp/2013/10/0401/Blue-question-mark-icon-1004195336.png'/>"))), value = "put text here"),
checkboxInput("checkbInp",c("Checkbox1",list(HTML("<img src='http://www2.psd100.com/ppp/2013/10/0401/Blue-question-mark-icon-1004195336.png'/>"))), value = T),
checkboxInput("checkbInp2",c("Checkbox2",list(HTML("<img src='http://www2.psd100.com/ppp/2013/10/0401/Blue-question-mark-icon-1004195336.png'/>")))),
checkboxInput("checkbInp3",c("Checkbox3",list(HTML("<img src='http://www2.psd100.com/ppp/2013/10/0401/Blue-question-mark-icon-1004195336.png'/>"))))
),
mainPanel())
)
)
server <- function(input, output) {}
shinyApp(ui, server)
答案 1 :(得分:0)
如果不需要span标记,请尝试这样:
textInput("textInputObject", c("Input Header", tags$img(src = "http://www2.psd100.com/ppp/2013/10/0401/Blue-question-mark-icon-1004195336.png", title = "help", alt = ""), value = "put text here")