https://github.com/nhs-r-community/NHSRtheme
R package that helps to create plots that follow the NHS Identity
https://github.com/nhs-r-community/NHSRtheme
nhs package
Last synced: 5 months ago
JSON representation
R package that helps to create plots that follow the NHS Identity
- Host: GitHub
- URL: https://github.com/nhs-r-community/NHSRtheme
- Owner: nhs-r-community
- License: other
- Created: 2019-03-08T14:45:07.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-11-26T13:43:05.000Z (5 months ago)
- Last Synced: 2024-11-26T14:34:26.796Z (5 months ago)
- Topics: nhs, package
- Language: R
- Homepage: https://nhs-r-community.github.io/NHSRtheme
- Size: 2.64 MB
- Stars: 29
- Watchers: 4
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.Rmd
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - nhs-r-community/NHSRtheme - R package that helps to create plots that follow the NHS Identity (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.height = 3,
fig.width = 5
)
```# NHS-R Theme
*This package is part of the NHS-R Community suite of [R packages](https://nhsrcommunity.com/packages.html).*
[](https://github.com/nhs-r-community/NHSRtheme/actions)
[](https://github.com/nhs-r-community/NHSRtheme/actions/workflows/R-CMD-check.yaml)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/).
This package will also produce xaringan presentation slides that can be viewed as HTML. For more details please see the vignette provided.
# 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')
```