在我的大学的一个数据科学项目中,我们被要求制作一棵决策树来模拟哪些客户可能会对活动做出回应或不会做出回应。这项任务的要求之一是制作一个混淆矩阵,我将其转换为数据帧。这是我生成的数据框。
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"));
然后,我使用此代码将其转换为格式表。
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,用于将格式表放入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和我已经在线搜索过了,但我找不到一种方法来更改标题或行名的字体。如果有人对此有解决方案,我将永远感激不尽!如果有人知道一些可以改变整个表的字体系列的代码,我也会非常高兴。
注意:我确实理解了一个关于更改标题外观的问题,How to change appearance of table header row with R formattable package,但是,这个问题没有得到回答,也没有解决更改字体系列的问题。
发布于 2017-02-22 20:34:49
@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%
}
https://stackoverflow.com/questions/42391493
复制相似问题