knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

testpackage

The goal of testpackage is to provide some helper functions for people working with HSRC or other projects.

There are currently three independent tools.

pretty_plot adds a logo and some text (e.g. source, date etc) to a plot. theme_HSRC creates a ggplot theme QR_save generates a series of QR codes from a csv file of URLs and titles. Useful for presentations.

Installation

You can install the development version of testpackage from GitHub with:

# install.packages("devtools")
devtools::install_github("IainMoppett/testpackage")

Example

QR_save

Use the QR_save function to save a series of pdfs of QR codes with a helpful title. Online tools tend to give a rather unhelpful 'file.png' as the output.

library(testpackage)
## basic example code

QR_save(system.file("extdata", "QR_Data.csv", package = "testpackage"))

Pretty_plot

Adds a logo at the bottom right and some text (e.g. data source) at the bottom left. Plots can be set-up using whatever themes you choose. Or you can override the theme with theme_HSRC by setting theme_apply to TRUE.

You can also add facet plot formatting in the same style with facet_apply as TRUE.

Two native test plots

library(testpackage)
library(ggplot2)

pl_1 <- ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point()
pl_1_no_legend <- ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point(show.legend = FALSE)

pl_1
pl_1_no_legend

Pretty_plot function applied to the test plots

pp_pl_1 <- pretty_plot(pl_1, source = "Text 14 point, native theme",
logo_path = system.file("extdata", "SNAP3_2019.jpg", package = "testpackage"),
text_size = 14,
theme_apply = FALSE)

pp_pl_1

pp_pl_1_no_legend <- pretty_plot(pl_1, source = "Text 16 point, HSRC theme",
logo_path = system.file("extdata", "SNAP3_2019.jpg", package = "testpackage"),
text_size = 16,
theme_apply = TRUE)
pp_pl_1_no_legend


IainMoppett/testpackage documentation built on Feb. 4, 2023, 11 p.m.