如何更改 R 格式表中的字体系列?

How do you change the font family in a formattable in R?

在我大学的一个数据科学项目中,我们被要求制作一个决策树来模拟哪些客户可能响应或不响应活动。该任务的要求之一是制作一个混淆矩阵,我将其转换为数据框。这是我生成的数据框。

    confusionMatrixCARTDecisionTree <- data.frame("Number Predicted to Not Subscribe" = 
    c(36006, 542), "Number Predicted to Subscribe" = c(3554, 1086), 
    row.names = c("Number of Individuals that Subscribed", 
    "Number of Individuals that didn't Subscribe"));

然后我使用这段代码将其转换为格式table。

    formattableConfusionMatrixCARTDecisionTree <- formattable(
    confusionMatrixCARTDecisionTree, align = "c", 
    list("Predicted Number not Subscribing" = color_tile("white", "yellow"),     
    "Predicted Number Subscribing" = color_tile("yellow", "white")));

然后是我在这里找到的函数 https://github.com/renkun-ken/formattable/issues/26,用于将格式table 放入 pdf 报告中。但是,我现在要做的是将字体系列更改为混淆矩阵的 CMU Serif,以便与 LaTeX 文件保持一致。我已经弄清楚如何更改列的字体,如下所示:

    formattableConfusionMatrixCARTDecisionTree <- 
    formattable(confusionMatrixCARTDecisionTree, list("Predicted Number not Subscribing" = 
    formatter("span", style=style("font-family" = "CMU Serif"))));

但是,我已经通读了此处 https://cran.r-project.org/web/packages/formattable/formattable.pdf 的文档,并且在网上进行了搜索,但找不到更改标题字体或行名称的方法。如果有人对此有解决方案,我将永远感激不已!如果有人知道一些可以改变整个 table.

字体系列的代码,我也会非常高兴

注意:我知道这里有人问了一个与更改标题外观有关的问题 How to change appearance of table header row with R formattable package,但是,这个问题没有得到解答,也没有解决更改字体系列的问题。

@font-face {
   font-family: 'Name';
   src:url('../fonts/Name.eot?#') format('eot'),url('../fonts/Name.woff') format('woff'),url('../fonts/Name.ttf') format('truetype');
}
html {
   height:100%
}
body{
   font-family:Name,Tahoma,tahoma,Arial;
   background-color:#fafafa;
   height:100%
}