I am trying to include a table in a Word document but with no results. What I get in the resulting document is just a text list of the elements of the table including column names.
My code is organized in two scripts:
Script calling Markdown file KG-report.Rmd
rmarkdown::render("KG-report.Rmd", params = list(
pest.name = pest.name),
output_file = paste0("Report-", pest.name, ".docx")
Markdown script KG-report.Rmd
---
title: "Some title"
author: "me"
date: "`r Sys.Date()`"
output:
officedown::rdocx_document:
reference_docx: Simple_master_template_opinions.docx
tables:
style: Table
params:
pest.name: "Default pest"
---
```{r process-map, echo=FALSE, warning=FALSE, message=FALSE, fig.keep='all'}
# create and check directories
source("R_scripts\\PEST.PROFILE.check.pest.directories.r", local = knitr::knit_global())
# download distribution tables or load reviewed distribution table
source("R_scripts\\PEST.PROFILE.web.EPPO.distribution.table.r", local = knitr::knit_global())
knitr::kable(pest.kg.table)
etc...
After many tests and after following suggestions on word formatting (e.g. here) which did not solve the issue, it looks like the problem is related to looping on
rmarkdown::render()
If I do not use it the table is printed.... Is there any known issue about this or am I just using it in the wrong way? Thank you
UPDATE - SOLUTION FOUND
In the end I was able to find a solution. It looked like the kable function was printing a html table in the word file which resulted in text with no table formatting. Adding the argument format = "pipe"
solved the issue.