-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
146 lines (100 loc) · 4.95 KB
/
README.Rmd
File metadata and controls
146 lines (100 loc) · 4.95 KB
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
---
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%"
)
```
<!-- badges: start -->
[](https://www.repostatus.org/#active)
[](https://github.com/AAGI-Org-AU-Public/AAGIThemes/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
# {AAGIThemes} AAGI Branding for R Graphical and Tabular Outputs <img align="right" src="man/figures/logo.png">
This repository contains the code for the R package {AAGIThemes}, which once installed in your R session (local or RStudio Server), provides helper functions for creating and exporting graphics created in R with a unified style that follows the AAGI brand guidelines.
The goal of {AAGIThemes} is to provide easy to use theming of R graphics for AAGI team members.
Following AAGI's brand guidelines, AAGI colours are used where applicable and the font defaults to Proxima Nova.
The resulting graphs, plots and charts feature a x and y axis that meet at 0 with no gridlines, but these can optionally be set to appear.
## Installation instructions
{AAGIThemes} is available through the [R-Universe](https://r-universe.dev/search) with pre-built binaries (this is the easy way).
To get started:
### Enable this universe
```r
options(repos = c(
aagi_aus = 'https://aagi-aus.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
```
### Install
```r
install.packages("AAGIThemes")
```
## Quick start
Following are some quick examples of {AAGIThemes} functionality.
However, you may wish to browse the vignette for a more detailed look at what the package offers using:
```r
vignette("AAGIThemes", package = "AAGIThemes")
```
### Create tabular outputs
{AAGIThemes} provides [{flextable}](https://davidgohel.github.io/flextable/) and [{gt}](https://gt.rstudio.com) themes suited for the AAGI style that works in HTML and Word document outputs.
#### Creating Themed {flextable} Outputs
You can use it like so with {flextable}.
```r
library(AAGIThemes)
library(dplyr)
library(flextable)
flextable(head(airquality)) |>
mutate(`Month Name` = "May") |>
theme_ft_aagi()
```
### Plots and graphs
{AAGIThemes} provides several functions to assist users in creating plots, charts and graphs with a more unified AAGI style.
For creating standalone graphs using R's base library there are:
* `barplot_aagi()`,
* `boxplot_aagi()`,
* `hist_aagi()`, and
* `plot_aagi()`.
#### Using the basic plot functions
Example of how the base graphics functionality with AAGI style pre-applied is used:
```{r boxplot_aagi, fig.cap="An example plot illustrating the use of AAGIThemes with R's base plot capabilities."}
library(AAGIThemes)
boxplot_aagi(decrease ~ treatment,
data = OrchardSprays,
xlab = "treatment",
ylab = "decrease"
)
```
See the respective function's help files and the {AAGIThemes} cookbook for more examples and documentation.
#### Using With {ggplot2}
The function `theme_aagi()` is provided to apply a unified style for creating AAGI themed plots, charts and graphs using {ggplot2}.
The function is very basic and provides only one parameter, `base_size`, which is used to set the font size (in points) used in the resulting figure.
No adjustments are made by the type of graph being produced, so you may wish to add grid lines or change the colour palette that is used to alter point or line colours in your graph.
Example of how `theme_aagi()` is used in a standard {ggplot2} workflow:
```{r theme_aagi_ggboxplot, fig.cap="An example plot illustrating the use of AAGIThemes with ggplot2."}
library(AAGIThemes)
library(ggplot2)
ggplot(data = OrchardSprays, aes(x = treatment, y = decrease)) +
geom_boxplot() +
scale_y_continuous(breaks = seq(0, 120, by = 20)) +
theme_aagi()
```
### Maps
Example of a map made with {ggplot2} and {AAGIThemes}.
```{r theme_aagi_map, fig.cap="An example map illustrating the use of AAGIThemes with ggplot2."}
library(AAGIThemes)
library(AAGIPalettes)
library(ggplot2)
library(ozmaps)
sf_oz <- ozmap_data("states")
ggplot(sf_oz, aes(fill = NAME)) +
geom_sf() +
coord_sf(crs = "+proj=lcc +lon_0=135 +lat_0=-30 +lat_1=-10 +lat_2=-45 +datum=WGS84") +
scale_fill_manual(values = unname(palette.colors(palette = "Okabe-Ito"))) +
theme_aagi()
```
## Logo Rights
The logo of this project and the AAGI strategic partners do not come under MIT License.
The Analytics for the Australian Grains Industry (AAGI) project retains full rights to the AGGI logo and the Grains Research and Development Corporation (GRDC) and strategic partners, Curtin University, the University of Queensland and Adelaide University, retain full rights to their own logos, respectively.