-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
150 lines (114 loc) · 4.31 KB
/
README.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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dev = "ragg_png",
dpi = 300
)
```
# twriTemplates
<!-- badges: start -->
[![twriTemplates status badge](https://txwri.r-universe.dev/badges/twriTemplates)](https://txwri.r-universe.dev)
[![R build status](https://github.com/TxWRI/twriTemplates/workflows/R-CMD-check/badge.svg)](https://github.com/TxWRI/twriTemplates/actions)
[![codecov](https://codecov.io/gh/TxWRI/twriTemplates/branch/main/graph/badge.svg?token=THDM1CMA83)](https://app.codecov.io/gh/TxWRI/twriTemplates)
<!-- badges: end -->
This package provides:
- Rmarkdown templates for MS Word and pdf documents that follow recommended brand guidance
- ggplot themes for common design styles between projects
- custom pkgdown template for TWRI packages
## Installation
The easiest way to install twriTemplates is through the r-universe repository:
```{r eval=FALSE}
options(repos = c(
txwri = 'https://txwri.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
install.packages("twriTemplates")
```
twriTemplates also lives on Github and can be built from source using:
```{r eval=FALSE}
install.packages("remotes")
remotes::install_github("TxWRI/twriTemplates")
```
## Usage
### Prerequisites
The Rmarkdown templates assume the required fonts are installed on your system. The `Minion Pro` font among others are used by the various templates and themes. We aren't licensed to distribute some of the fonts. Install all the fonts AgriLife provides at the [Marketing and Communications branding website](https://agrilife.tamu.edu/marketing-and-communications/resources/branding-agrilife/).
In order to use the pdf template, please install the tinytex package:
```{r eval=FALSE}
install.packages("tinytex")
tinytex::install_tinytex()
tinytex::is_tinytex()
```
Make sure the last function returns `TRUE`.
### Templates
Create a new Rmarkdown document, select "From Template", and the TWRI PDF template and TWRI doc template will be available in the list.
![Screenshot of rmarkdown template selector](inst/images/template.png)
A new .Rmd file will open with example text and guidance in the document.
### Theme
ggplot themes are provided for print and powerpoint presentation. The main difference is that the fonts on the presentation styled theme are scaled larger to facilitate reading from the back row in an auditorium. There is also a function to add TWRI branding to your plots.
```{r reporttheme, fig.width=6.5, fig.height=4}
library(twriTemplates)
library(ggplot2)
library(dplyr)
## report theme
p1 <- dissolved_oxygen %>%
mutate(station_id = as.factor(station_id)) %>%
ggplot(aes(station_id,
min_do,
fill = station_id,
color = station_id)) +
geom_boxplot(alpha = 0.5) +
geom_jitter(alpha = 0.9, width = 0.1, height = 0) +
theme_TWRI_print() +
scale_color_discrete_twri(name = "Station ID") +
scale_fill_discrete_twri(name = "Station ID") +
labs(x = "Station ID",
y = "Dissolved Oxygen, Min [mg/L]",
title = "24-hr Minimum Dissolved Oxygen, Tres Palacios River",
caption = "Source: TCEQ SWQM")
p1
```
```{r prestheme, fig.width=10, fig.height=7.5}
## presentation theme
## suggested export size is 10 inches wide by 7.5 inches tall.
p2 <- dissolved_oxygen %>%
mutate(station_id = as.factor(station_id)) %>%
ggplot(aes(x = min_do,
fill = station_id,
color = station_id)) +
geom_histogram(alpha = 0.5) +
facet_wrap(~station_id) +
theme_TWRI_pres() +
scale_color_discrete_twri(name = "Station ID") +
scale_fill_discrete_twri(name = "Station ID") +
labs(x = "Dissolved Oxygen, Min [mg/L]",
y = "n measurements",
title = "24-hr Minimum Dissolved Oxygen, Tres Palacios River",
caption = "Source: TCEQ SWQM") +
theme(legend.position = "none")
p2
```
```{r logo, fig.width=10, fig.height=7.5}
add_TWRI_logo(p2, scale = 0.2)
```
### pkgdown
add/edit _pkgdown.yaml in the package root directory:
```{yaml}
template:
package: twriTemplates
bootstrap: 5
navbar:
type: dark
bg: dark
structure:
right: [search, github]
```
add the following to the DESCRIPTION:
```
Config/Needs/website: TxWRI/twriTemplates
```