I often write papers with correlation matrices. I would like to be able to export the correlation matrix to Excel in xls or xlsx format. I would also like to format in bold correlations that meet a threshold (e.g., > .2). I was thinking maybe XLConnect might provide the functionality.
In order to make the example simple, assume the data frame is as follows, and assume I want to bold all cells greater than 5.
x <- data.frame(matrix(1:9, nrow = 3))
# > x
# X1 X2 X3
# 1 1 4 7
# 2 2 5 8
# 3 3 6 9
As an aside, I note that solutions have been proposed for cellbolding for markdown:
- How to bold a cell in a table (kable) in rmarkdown?
- Bold formatting for significant values in a Rmarkdown table
I've also found this answer, but it is not a very general solution in that it takes quite a bit to adapt it to the general task of taking a data frame and a formatting rule:
export data frames to Excel via xlsx with conditional formatting