【问题标题】:Shiny html tags in a vector矢量中闪亮的 html 标签
【发布时间】:2016-06-30 21:08:35
【问题描述】:

我正在尝试使用 html 标签(闪亮)并尝试将这些功能应用于矢量。换句话说,我正在尝试类似:

library(shiny)
tags$p(letters)

这会导致以下警告:

Warning message:
In charToRaw(enc2utf8(text)) :
  argument should be a character vector of length 1
all but the first element will be ignored

如何获得:

  <p>a</p>
  <p>b</p>
  <p>c</p>

等等

我使用了 lapply (lapply(letters,tags$p)),几乎到了那里,但我无法将它作为单个向量与每个字符串一起取消列出。

【问题讨论】:

    标签: html r shiny


    【解决方案1】:

    你可以试试

    sapply(letters,function(i) as.character(tags$p(i)))
    

    如果你想把它作为一个字符值试试

    cat(paste(sapply(letters[1:3],function(i) as.character(tags$p(i))),collapse="\n")) 
    <p>a</p>
    <p>b</p>
    <p>c</p>
    

    【讨论】:

      猜你喜欢
      • 2021-09-10
      • 1970-01-01
      • 1970-01-01
      • 2018-08-05
      • 2019-04-29
      • 1970-01-01
      • 1970-01-01
      • 2016-02-20
      • 2019-02-22
      相关资源
      最近更新 更多