如何将 css 样式元素添加到 Rmd shiny renderImage?

How do I add css style element to Rmd shiny renderImage?

我正在努力将 css 样式元素添加到我闪亮的 renderImage 代码中。 我尝试了通过 tag$link 使用 css 源文件以及通过 tag$style.css 直接代码的各种选项。

我已经尝试了 tag$link 和 tag$style 选项(在我的示例代码中) (1) 在 renderImage 代码之外 (2) 在 renderImage 代码内部,在 list wrapper 外部 (3) 在 renderImage 代码内部,在列表包装器内部

我遇到以下两个错误之一: 错误 1:'closure' 类型的对象不可子集化 错误 2:找不到对象 'centerImage'

在我的本地机器上使用我的 logo5.png 图像,没有额外的 css - 它有效。 我的 logo5.png 图片在我的本地机器上,还有额外的 css - 它不起作用。

请注意,我在 renderImage 之前在我的代码中留下了“1”、dir() 和“2”以跟踪执行。

有人可以帮忙吗?

(要在Rstudio中运行,将rrr``改成4处的3个反引号)

(我的在线图片 URL 是 http://www.richpat.com/wp-content/uploads/2019/04/logov5.png

---
title: 'Shiny Dev with Logo'
output: 
  flexdashboard::flex_dashboard:
    theme: united
  orientation: columns
source_code: embed
runtime: shiny
---

rrr``{r setup, include=FALSE}        #CORRECT THIS WHEN RUNNING
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(flexdashboard,quietly=TRUE, verbose=FALSE)
library(shiny,quietly=TRUE, verbose=FALSE)
library(plotly,quietly=TRUE, verbose=FALSE)
rrr``                                #CORRECT THIS WHEN RUNNING

Corporate
=======================================================================

Column
-----------------------------------------------------------------------

### Logo

rrr``{r}                              #CORRECT THIS WHEN RUNNING
(1)
dir()
#tag$head(tags$link(rel = "stylesheet", type = "text/css", href = "BRstyle.css"))
#tag$head(tag$style("centerImage {text-align:center;}"))

(2)
renderImage({
      rfilename=normalizePath("logov5.png")
      list(src=rfilename, contentType = "image/png", alt = "logo5", class=centerImage)
      }, deleteFile = FALSE)
rrr``                                 #CORRECT THIS WHEN RUNNING

Background
=======================================================================

Column
-----------------------------------------------------------------------

### Purpose

ad valorem libram

好的 - 所以我找到了答案。简单是路线...

我没有在 shiny renderImage 中执行此操作,而是学到了很多有关 shiny 和 flexdashboard 以及 markdown 如何协同工作的知识!!!

我使用 img html 标签作为带有直接显示标签的降价部分的一部分

<img src="http://www.richpat.com/wp-content/uploads/2019/04/logov5.png"
 alt="Markdown Monster icon"
 style="ftext-align:center; display: center;" />

我删除了完整的闪亮 renderImage r 代码部分

作为奖励 - 只是为了展示更多我学到的东西,这是我修改后的 yaml

title: 'Br F A'
output: 
  flexdashboard::flex_dashboard:
    logo: logov5s.png
    theme: readable
    css: BRstyle.css
    navbar: 
    - { title: "About", href: "http://www.richpat.com", align: left }
    source_code: embed
    orientation: columns
runtime: shiny