将网站链接到闪亮框架内的标题

linking a website to a caption within shiny framework

我正在尝试 link 一个网站到嵌入在标题中的单词 "FAQ"。当用户点击常见问题解答时,我试图将用户引导到一个新网页。

这是我的代码。

请参阅"caption = ("注意:有关困难指标的更多信息,请参阅常见问题解答。"​​),"

Diff_plot <- reactive({
ggplot(Diff_data(), aes(x =Difficulty_Type, y = Frequency_Difficulties)) + geom_bar(stat =
                                                                   "identity",
                                                                 position = "stack",
                                                                 fill = "#B61E2E") +
  geom_text(
    aes(label = Percentage),
    vjust = 1,
    colour = "white", 
    position = position_dodge(width=0.9),
    fontface = "bold",
    size=5,
   # angle = 90,
    hjust = 0.5
  ) +
  labs(
    x = "",
    y = "Frequecny",



caption = ("Note: See FAQ for more information on difficulties indicators."),


    face = "bold"
  ) +
  theme_bw() + scale_y_continuous(labels = scales::comma) +
  theme(plot.title = element_text(
    hjust = 0.5,
    size = 15,
    colour = "Black",
    face = "bold"
  ),
  plot.caption = element_text(hjust = 0, color = "black", face = "bold", size=12.5),
  axis.text=(blue.bold.12.text), axis.title=blue.bold.14.text, axis.text.x = element_text(angle = -75, vjust = 0, hjust=0)) +
  ggtitle(
    paste(
      "Population by Type of Difficulty in",
      input$county_Diff,
      "for",
      input$sex_diff,
      "(", 
      input$Age_Group_Diff,
      ")"
    )
  )

  })

我认为这是不可行的 - ggplot 创建一个图像,然后在您闪亮的应用程序中呈现,并且标题是图像的一部分,而不是单独 HTML 包围它。如果您 运行 您的应用程序并检查源代码 HTML,您将在绘图所在的位置看到 <img> 标签。

所以你最好的选择就是假装你有一个标题,而不是在你闪亮的应用程序中使用不同的 UI - 像:

ui <- fluidPage(

  plotOutput(outputId = "diff_plot"),
  div(tags$p("See the", a("FAQ", href = "...", target = "_blank"), "for more info"),
      style = "text-align: right;")

)

server <- function(input, output) {

  Diff_plot <- reactive({ ... })
  output$diff_plot <- renderPlot({ Diff_plot() })

}

如果您希望 link 在新选项卡中打开而不是重定向当前页面,请注意 target = "_blank" 是必需的。