forked from nhs-r-community/NHSRtheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
83 lines (56 loc) · 1.94 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
---
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-",
fig.height = 3,
fig.width = 5
)
```
# NHS R Theme <a href='https://nhsrcommunity.com/'><img src='man/figures/logo.png' align="right" height="80" /></a>
<!-- badges: start -->
[![R build status](https://github.com/nhs-r-community/nhsrtheme/workflows/R-CMD-check/badge.svg)](https://github.com/nhs-r-community/nhsrtheme/actions)
<!-- badges: end -->
This repo attempts to build an R package that can provide themes to ggplot for producing charts that follow the [NHS Identity](https://www.england.nhs.uk/nhsidentity/).
# Installing nhsrtheme
`{nhsrtheme}` is not currently on CRAN, so you will have to install it directly from Github using devtools.
If you do not have the devtools package installed, you will have to run the first line in the code below as well.
```{r eval=FALSE}
# install.packages('devtools')
devtools::install_github('nhs-r-community/nhsrtheme')
```
## Examples
```{r,setup_bars}
library(ggplot2)
library(nhsrtheme)
df <- data.frame(x = c("a", "b", "c", "d"), y = c(3, 4, 1, 2))
bars <- ggplot(df, aes(x, y, fill = x)) +
geom_bar(stat = "identity") +
labs(x = NULL, y = NULL) +
theme(legend.position = "none")
```
```{r default_bars}
bars + scale_fill_nhs()
```
```{r blues_bars}
bars + scale_fill_nhs(palette = 'blues')
```
```{r neutral_bars}
bars + scale_fill_nhs(palette = 'neutrals')
```
```{r green_bars}
bars + scale_fill_nhs(palette = 'support greens')
```
```{r highlights_bars}
df2 <- data.frame(x = c("a", "b", "c", "d", "e", "f" ,"g", "h"),
y = c(3, 4, 1, 2, 5, 9, 7, 4))
bars2 <- ggplot(df2, aes(x, y, fill = x)) +
geom_bar(stat = "identity") +
labs(x = NULL, y = NULL) +
theme(legend.position = "none")
bars2 + scale_fill_nhs(palette = 'highlights')
```