-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreporting_template.RMD
190 lines (141 loc) · 9.19 KB
/
reporting_template.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
---
title: "ANALYSIS REPORT" # set the main report title
author:
# - Jane Doe^[Institution Two, jane@example.org] # add report authors (uncomment if using)
# - John Doe^[Institution One, john@example.org] # add a second report author (uncomment if using)
date: "Date: `r format(Sys.time(), '%d/%m/%Y')`"
always_allow_html: true
output:
bookdown::html_document2:
toc: true # create a table of contents (true or false)
toc_depth: 2 # set the table of contents depth (number)
number_sections: false # choose whether or not to number sections (true or false)
toc_float: true
self_contained: yes
css: esr-styles.css
highlight: pygments
includes:
after_body: esr_footer.html
---
<img src="./images/ESR_logo.svg" style="position:absolute;top:19px;right:40px;width:23%;" />
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, error = FALSE, message = FALSE)
```
## Table example
```{r env, eval=T}
# load libraries
library(dplyr)
library(flextable)
library(ggplot2)
library(scales)
library(plyr)
library(bookdown)
library(ape)
htmltools::tagList(rmarkdown::html_dependency_font_awesome())
```
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
```{r table}
# example table with ESR specific formatting
set_flextable_defaults(
font.family = "Arial",
font.size = 11,
font.color = "black",
table.layout = "fixed",
digits = 1,
theme_fun = "theme_box"
)
# use mtcars
mtcars_sorted <- mtcars %>% arrange(cyl, gear)
# create table
table1 <- as_grouped_data(mtcars_sorted, groups = "cyl") %>%
as_flextable() %>%
autofit()
table1 <- bg(table1, bg = "#000000", part = "header")
table1 <- color(table1, color = "white", part = "header")
table1 <- color(table1, part = "footer", color = "#666666")
table1 <- bg(table1, i = ~ !is.na(cyl), bg = "#0097db", part = "body")
table1 <- color(table1, i = ~ !is.na(cyl), color = "white", part = "body")
table1 <- bold(table1, j = 1, i = ~ !is.na(cyl))
table1 <- align(table1, j = 1, i = ~ !is.na(cyl), align = "left", part = "body")
# add caption
table1 <- set_caption(
table1,
"Caption can go here if needed.",
autonum = NULL,
# style = "Table Caption",
html_escape = TRUE
)
# print table
table1
```
-----
## Include text and hyperlinks
### Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum <sup>[1]</sup>.
<sup>[1]</sup> [Variants_of_Concern_VOC_Technical_Briefing_18.pdf](https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1001358/Variants_of_Concern_VOC_Technical_Briefing_18.pdf)
### Consectetur adipiscing elit
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
### Sed do eiusmod tempor incididunt
Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
-----
## Plot example
### Bar plot
```{r barplot, fig.cap="Caption can go here if needed.", fig.topcaption=TRUE, fig.align="center"}
# create data
df2 <- data.frame(supp=rep(c("VC", "OJ"), each=3),
dose=rep(c("D0.5", "D1", "D2"),2),
len=c(6.8, 15, 33, 4.2, 10, 29.5))
# Sort by dose and supp
df_sorted <- arrange(df2, dose, supp)
# Calculate the cumulative sum of len for each dose
df_cumsum <- ddply(df_sorted, "dose",
transform, label_ypos=cumsum(len))
# Create the barplot
ggplot(data=df_cumsum, aes(x=dose, y=len, fill=supp)) +
geom_bar(stat="identity")+
geom_text(aes(y=label_ypos, label=len), vjust=1.6,
color="white", size=3.5)+
scale_fill_brewer(palette="Paired")+
theme_minimal()
```
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.
Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?
Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
```{r tree, echo=F, fig.cap="Caption can go here if needed.", fig.topcaption=TRUE, fig.align="center"}
tree <- ape::read.tree("data/tree_newick.nwk")
co <- c(rep("#0097db", 12), rep("#febf2a", 4))
plot(tree,
edge.col = co,
tip.color = "black")
```
-----
**Notice of Confidential Information:**
If you receive this report in error, please notify the sender immediately. The information contained in this report is legally privileged and confidential. Unauthorized use, dissemination, distribution or reproduction of this report is prohibited.
-----
## Additional elements
**Note:** this section is for demonstration purposes only, it should be removed from actual reports/documents.
This section is here to show a collection of additional elements that can be used to construct and theme the documents.
### Information boxes
If ever required there is the option to have bootstrap-styled "information boxes". These have been coloured according to the "official" ESR colours.
<div class="alert alert-custom-blue">
<strong>ESR blue</strong> - This is part of the official ESR colour scheme (#0097db).
</div>
<div class="alert alert-custom-green">
<strong>ESR green</strong> - This is part of the official ESR colour scheme (#85C659).
</div>
<div class="alert alert-custom-red">
<strong>ESR red</strong> - This is part of the official ESR colour scheme (#ec1515).
</div>
<div class="alert alert-custom-yellow">
<strong>ESR yellow</strong> - This is part of the official ESR colour scheme (#febf2a).
</div>
<div class="alert alert-custom-purple">
<strong>ESR purple</strong> - This is part of the official ESR colour scheme (#784f96).
</div>
<div class="alert alert-custom-lightgreen">
<strong>ESR lightgreen</strong> - This is part of the official ESR colour scheme (#1abcc1).
</div>