将图片添加到RShiny actionButton

时间:2017-05-26 11:46:59

标签: r shiny shinydashboard

如何将图像添加到RShiny操作按钮?就像一个jpeg文件......

shinyUI(fluidPage( 
  titlePanel("Image on button"),

  sidebarLayout(
    sidebarPanel(

    ),

    # Show a plot of the generated distribution
    mainPanel(
      actionButton("button","Submit"),
    )
  )
))

1 个答案:

答案 0 :(得分:1)

在我的解决方案之下

  shinyUI(fluidPage(
   titlePanel("Image on button"),
   sidebarLayout(
    sidebarPanel(
    ),

   #Show a plot of the generated distribution
    mainPanel(
      actionButton("button","Submit", ),
      tags$button(
        id = "my_button",
        class = "btn action_button",   
        tags$img(src = "http://i0.wp.com/unaracnidounacamiseta.com/wp-
        content/uploads/2012/07/lorem.jpg",height = "50px") #internet image
        #tags$img(src = "your_image.png",height = "50px") #local image
        ),     
       )
      )
     )
    )