In a project for Data Science at my University, we've been asked to make a decision tree to model which customers are likely to respond or not respond to a campaign. One of the requirements of the task was to make a confusion matrix, which I converted to a data frame. This is the data frame that I generated.
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"));
I then used this code to convert it into a formattable.
formattableConfusionMatrixCARTDecisionTree <- formattable(
confusionMatrixCARTDecisionTree, align = "c",
list("Predicted Number not Subscribing" = color_tile("white", "yellow"),
"Predicted Number Subscribing" = color_tile("yellow", "white")));
And then a function I found here, https://github.com/renkun-ken/formattable/issues/26, to put the formattable into a pdf report. However, what I'm trying to do now is to change the font family to CMU Serif of the confusion matrix so that it is consistent with the LaTeX file. I've worked out how to change the font for a column, like this:
formattableConfusionMatrixCARTDecisionTree <-
formattable(confusionMatrixCARTDecisionTree, list("Predicted Number not Subscribing" =
formatter("span", style=style("font-family" = "CMU Serif"))));
However, I have read through the documentation here https://cran.r-project.org/web/packages/formattable/formattable.pdf and I have searched online but I cannot find a way to change the font of the heading or the row names. If anyone had a solution to this I would be eternally grateful! I would also be extremely happy if anyone knew some code that would change the font family of the entire table.
Note: I do understand a question relating to changing the appearance of the heading was asked here How to change appearance of table header row with R formattable package, however, this was unanswered, and doesn't address the issue of changing the font family.
@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%
}