I have to compare some values in data and display weekly trends. I want to show if a value has increased from last week. I have created an rmarkdown report to do it. An example code is shown below, which works perfectly when output: html_document
but output is messed up when using output: word_document
---
title: "trials"
author: "Foo Bar"
date: "15 December 2016"
output: word_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r cars, echo=FALSE, cache=FALSE, message=FALSE}
library(dplyr, quietly = TRUE)
library(abind, quietly = TRUE)
virginica <- iris %>% filter(Species == "virginica") %>% head() %>% select(-Species)
setosa <- iris %>% filter(Species == "setosa") %>% head() %>% select(-Species)
diff_mat <- virginica - setosa
diff_mat[diff_mat<0] <- '<font color="green">⇓ </font>'
diff_mat[diff_mat>0] <- '<font color="red">⇑ </font>'
diff_mat[diff_mat == 0] <- '<font color="blue">⇔ </font>'
datArray <- abind::abind(virginica, diff_mat, along=3)
fin_dat <- apply(datArray,1:2, function(x)paste(x[1],x[2], sep = " "))
knitr::kable(fin_dat, format = "html",
escape = FALSE, table.attr = "border=1",
caption = "Changes across species")
```
How can I format the word version of the document similar to the html version?
Perhaps render("my_document.rmd", "Grmd::docx_document"). This works decently for html tables but is not compatiple with using a styles template. It does keep the table structure, including column spanners.