I am using RMarkdown to write some university work I have created a table using the code below and need to export it to Microsoft Word
Can anyone tell me how to add a label describing the data in the table or do I have to do this in MS Word afterwards
---
title: "Data"
author: "foo"
date: "2 July 2016"
output:
word_document:
bibliography: bibliography.bib
---
kable(table(Rawdata$Var1, Rawdata$Var2))
Use the caption
argument in kable
.
If you want more options for formatting tables in Word output, I would recommend downloading the Gmisc
package and using the Gmisc::docx_document
format. Just keep in mind that it will save the file as an HTML file that can be opened as a Word Document and preserve the formatting.
For example:
---
title: "Data"
author: "foo"
date: "2 July 2016"
output: Gmisc::docx_document
---
```{r}
knitr::kable(head(mtcars[, 1:3]),
caption = "This is the table caption")
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With