I have the following data :
library(data.table)
DT <- data.table(
Pays = c("Austria", "Belgium", "Brazil", "Bulgaria",
"Canada", "China", "Croatia", "Cyprus", "Czechia", "Denmark"),
`Nouveaux cas` = c("212.2", "136.0", "143.5", "258.7", "122.8",
"0.0", "615.0", "299.0", "327.7", "314.5"),
`Nouveaux décès` = c("53.8", "35.4", "14.9", "89.7", "14.2", "0.0", "79.0", "14.4", "47.3", "6.9"),
`Évolution du nombre de cas` = c("-21.5%", "2.8%", "5.6%", "-5.2%", "4.1%", "-0.9%", "5.5%", "34.3%", "36.7%", "73.8%"),
`Évolution du nombre de décès` = c("-20.1%", "-20.4%", "10.5%", "-8.5%", "24.1%", "NaN%", "2.9%", "63.6%", "-5.4%", "3.6%"))
> DT
Pays Nouveaux cas Nouveaux décès Évolution du nombre de cas Évolution du nombre de décès
1: Austria 212.2 53.8 -21.5% -20.1%
2: Belgium 136.0 35.4 2.8% -20.4%
3: Brazil 143.5 14.9 5.6% 10.5%
4: Bulgaria 258.7 89.7 -5.2% -8.5%
5: Canada 122.8 14.2 4.1% 24.1%
6: China 0.0 0.0 -0.9% NaN%
7: Croatia 615.0 79.0 5.5% 2.9%
8: Cyprus 299.0 14.4 34.3% 63.6%
9: Czechia 327.7 47.3 36.7% -5.4%
10: Denmark 314.5 6.9 73.8% 3.6%
I wonder the best way to get an object, to be inserted in a word file, that would be this table with one heatmap per column. I can export this table in Excel and use conditional formating to get the desired output :
Now I am unsure what is the best way to do that in R. My quick searches yielded me :
- Some heatmaps in
ggplot2
, e.g. here but it seems mainly two dimensional, and not to account for a lot of other options such as renaming columns and so on - Various packages to do tables, e.g. here, but then I am a bit lost in all the choices. I explored a bit the
gt
option a few weeks ago, but I do not recall there being this option, in addition to lacking a possibility to output vectorialized table (which would be ideal but not necessary)