-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWord_Example_2.Rmd
48 lines (34 loc) · 1.15 KB
/
Word_Example_2.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
title: "Introduction to RMarkdown"
author: "Greg Rousell"
date: "13/06/2020"
output:
word_document:
reference_docx: Word_Template.docx
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(flextable)
library(tidyverse)
```
## R Markdown with a Word Template
This is an R Markdown document that knits to a Word template. Using this feature you can control the appearance of your documents.
The `flextable` package will format R data frames into tables. For more information on `flextable` see: https://ardata-fr.github.io/flextable-book/index.html
```{r flextable}
summary_table <- iris %>%
group_by (Species) %>%
summarise (`Sepal Length` = round (mean (Sepal.Length),1),
`Sepal Width` = round (mean (Sepal.Width),1)
)
summary_table %>%
flextable()
```
## Including Plots
You can also embed plots, for example:
```{r plot, echo=FALSE, fig.height=2}
summary_table %>%
ggplot (aes(x = Species, y = `Sepal Length`)) +
geom_col (fill = "blue") +
theme_minimal()
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.