R:在闪亮的表输出中使单元格的一部分变为粗体

use*_*199 1 r shiny

我正在使用R闪亮的应用程序并使用renderTable和tableOutput创建表.是否有可能使单元格内容的一部分变为粗体,同时保持其余部分正常文本.

例如,特定单元格中的一个条目可能是:

5.3% ~1%~7

我尝试在适当的数字周围硬编码**,但它只输出了星号.

谢谢

Nic*_*icE 5

<strong></strong>如果你想要一些粗体文本,你可以在表格中使用HTML标签,这是一个例子:

library(shiny)
data<-data.frame(a=c("<strong>a</strong>","b"),val=c(1,2))

runApp(list(
        ui = basicPage(
                tableOutput('mytable')
        ),
        server = function(input, output) {
                output$mytable = renderTable({
                        data
                },sanitize.text.function=function(x){x})
        }
))
Run Code Online (Sandbox Code Playgroud)

您需要更改sanitize.text.function标识以便解释标记.

作为替代方案,您还可以使用数据表来呈现表格.您也可以使用<strong>标记,但请确保escaperenderDataTable部件中将选项设置为false .