Skip to content

Commit

Permalink
Merge pull request #10 from Public-Health-Scotland/data_export_fix
Browse files Browse the repository at this point in the history
Fix for unexported data objects.
  • Loading branch information
Tina815 authored Aug 6, 2024
2 parents 9a69629 + b99705a commit 3bba3e8
Show file tree
Hide file tree
Showing 19 changed files with 186 additions and 220 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
^docs$
^pkgdown$
^\.github$
^README\.html$
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: phsstyles
Title: Standard Graphic Styles for use in Public Health Scotland
Version: 0.1.1
Version: 0.1.2
Authors@R: c(
person("Tina", "Fu", email = "[email protected]", role = c("aut", "cre")),
person("Bob", "Taylor", email = "[email protected]", role = "aut")
Expand All @@ -17,6 +17,6 @@ Imports:
Suggests:
testthat (>= 3.0.0)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.0
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Config/testthat/edition: 3
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Generated by roxygen2: do not edit by hand

export(phs_colors)
export(phs_colour_values)
export(phs_colours)
export(phs_palette_types)
export(phs_palettes)
export(scale_color_continuous_phs)
export(scale_color_discrete_phs)
export(scale_colour_continuous_phs)
Expand Down
17 changes: 12 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# phsstyles 0.1.0 (2021-10-15)
# phsstyles 0.1.2 (2024-08-06)

- Initial package release.
- `phs_colours()`, `theme_phs()`, `scale_colour_discrete_phs()`,
`scale_colour_continuous_phs()`, `scale_fill_discrete_phs()` and
`scale_fill_continuous_phs()` functions added.
- Exported `phs_colour_values`, `phs_palettes` and `phs_palette_types`.
This now allows users to call phsstyles functions
without needing to load the package.

# phsstyles 0.1.1 (2022-05-30)

Expand All @@ -14,3 +13,11 @@
- Update the documentation for `phs_palettes` and `phs_palette_types`.

- Create a [pkgdown webpage](https://public-health-scotland.github.io/phsstyles/) so that readme, help pages and news page are integrated.

# phsstyles 0.1.0 (2021-10-15)

- Initial package release.
- `phs_colours()`, `theme_phs()`, `scale_colour_discrete_phs()`,
`scale_colour_continuous_phs()`, `scale_fill_discrete_phs()` and
`scale_fill_continuous_phs()` functions added.

70 changes: 0 additions & 70 deletions R/data.R

This file was deleted.

2 changes: 0 additions & 2 deletions R/phs_colours.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#'
#' @export
phs_colours <- function(colourname = NULL, keep_names = FALSE){
# load the vector phs_colour_values
phs_colour_values <- phsstyles::phs_colour_values

if (is.null(colourname)) {
phs_colour_values
Expand Down
98 changes: 70 additions & 28 deletions data-raw/phs_colour_values.R → R/phs_data.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
### This script creates the list of standard colours in Public Health Scotland
### based on Chart and Dashboard Accessibility Guidance.
###
### The resulting file is used inside the phs_colours function and is made
### available to users of the package via phsstyles::phs_colour_values
###
### This script should be re-run prior to every package release, to ensure the
### most up-to-date information provided by Chart and Dashboard Accessibility
### Guidance is used
###
### Any substantial changes to the data should be noted in the section
### pertaining to the latest release in the NEWS.md file

#' PHS colours and colour palettes
#'
#' @details
#'
#' ### PHS colours
#'
#' PHS colour names and their corresponding hex codes.
#'
#' `phs_colour_values` is a character vector that contains PHS colour names
#' in the PHS chart and dashboard guidance, such as PHS blue.
#'
#' ### PHS palettes
#'
#' A list grouping PHS colours into palettes.
#' It is used within \code{\link{scale_colour_discrete_phs}},
#' \code{\link{scale_colour_continuous_phs}},
#' \code{\link{scale_fill_discrete_phs}} and
#' \code{\link{scale_fill_continuous_phs}}.
#'
#' It contains PHS colour palettes such as main, main-purples.
#'
#' ### PHS palette types
#'
#' A list grouping PHS palettes into PHS palette types.
#' It is used within \code{\link{scale_colour_discrete_phs}},
#' \code{\link{scale_colour_continuous_phs}},
#' \code{\link{scale_fill_discrete_phs}} and
#' \code{\link{scale_fill_continuous_phs}}.
#'
#' It groups PHS palettes into two types - qualitative and sequential.
#'
#' The palettes and their types are listed below.
#'
#' | **Qualitative** | **Sequential** |
#' | --- | --- |
#' | main | x |
#' | supporting | x |
#' | all | x |
#' | x | main-purples |
#' | x | main-magentas |
#' | x | main-blues |
#' | x | main-greens |
#' | x | supporting-graphites |
#' | x | supporting-teals |
#' | x | supporting-liberties |
#' | x | supporting-rusts |
#'
#' @source \url{http://spark.publichealthscotland.org/media/2176/chart-and-dashboard-accessibility-guidance-version-12.pdf}
#'
#'
#' @rdname phs_data
#' @format `phs_colour_values` - A `character` vector of PHS colours and hex codes.
#' @export
phs_colour_values <- c(
# main palette, for qualitative plots
"phs-purple" = "#3F3685",
Expand Down Expand Up @@ -57,56 +97,58 @@ phs_colour_values <- c(
"phs-rust-30" = "#EEC4BA",
"phs-rust-10" = "#F9EBE8")

#' @rdname phs_data
#' @format `phs_colour_palettes` - A `list` of PHS colours grouped into palettes.
#' @export
phs_palettes <- list(
"main" = phsstyles::phs_colours(c("phs-purple", "phs-magenta",
"main" = phs_colours(c("phs-purple", "phs-magenta",
"phs-blue", "phs-green"), keep_names = TRUE),
"supporting" = phsstyles::phs_colours(c("phs-graphite", "phs-teal",
"supporting" = phs_colours(c("phs-graphite", "phs-teal",
"phs-liberty", "phs-rust"),
keep_names = TRUE),
"all" = phsstyles::phs_colours(c("phs-purple", "phs-magenta",
"all" = phs_colours(c("phs-purple", "phs-magenta",
"phs-blue", "phs-green",
"phs-graphite", "phs-teal",
"phs-liberty", "phs-rust"), keep_names = TRUE),
"main-purples" = phsstyles::phs_colours(c("phs-purple", "phs-purple-80",
"main-purples" = phs_colours(c("phs-purple", "phs-purple-80",
"phs-purple-50", "phs-purple-30",
"phs-purple-10"), keep_names = TRUE),
"main-magentas" = phsstyles::phs_colours(c("phs-magenta", "phs-magenta-80",
"main-magentas" = phs_colours(c("phs-magenta", "phs-magenta-80",
"phs-magenta-50", "phs-magenta-30",
"phs-magenta-10"),
keep_names = TRUE),
"main-blues" = phsstyles::phs_colours(c("phs-blue", "phs-blue-80",
"main-blues" = phs_colours(c("phs-blue", "phs-blue-80",
"phs-blue-50", "phs-blue-30",
"phs-blue-10"), keep_names = TRUE),
"main-greens" = phsstyles::phs_colours(c("phs-green", "phs-green-80",
"main-greens" = phs_colours(c("phs-green", "phs-green-80",
"phs-green-50", "phs-green-30",
"phs-green-10"), keep_names = TRUE),
"supporting-graphites" = phsstyles::phs_colours(c("phs-graphite",
"supporting-graphites" = phs_colours(c("phs-graphite",
"phs-graphite-80",
"phs-graphite-50",
"phs-graphite-30",
"phs-graphite-10"),
keep_names = TRUE),
"supporting-teals" = phsstyles::phs_colours(c("phs-teal", "phs-teal-80",
"supporting-teals" = phs_colours(c("phs-teal", "phs-teal-80",
"phs-teal-50", "phs-teal-30",
"phs-teal-10"),
keep_names = TRUE),
"supporting-liberties" = phsstyles::phs_colours(c("phs-liberty",
"supporting-liberties" = phs_colours(c("phs-liberty",
"phs-liberty-80",
"phs-liberty-50",
"phs-liberty-30",
"phs-liberty-10"),
keep_names = TRUE),
"supporting-rusts" = phsstyles::phs_colours(c("phs-rust", "phs-rust-80",
"supporting-rusts" = phs_colours(c("phs-rust", "phs-rust-80",
"phs-rust-50", "phs-rust-30",
"phs-rust-10"),
keep_names = TRUE))

#' @rdname phs_data
#' @format `phs_palette_types` - A `list` of PHS palettes grouped into palette types.
#' @export
phs_palette_types <- list(
qual = c("main", "supporting", "all"),
seq = c("main-purples", "main-magentas",
"main-blues", "main-greens",
"supporting-graphites", "supporting-teals",
"supporting-liberties", "supporting-rusts"))

usethis::use_data(phs_colour_values, phs_palettes, phs_palette_types,
overwrite = TRUE)
3 changes: 0 additions & 3 deletions R/phs_pal1.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
phs_pal1 <- function(n, name) {
# load the list phs_palettes
phs_palettes <- phsstyles::phs_palettes

if (!(name %in% names(phs_palettes))) {
stop(paste(name,"is not a valid palette name.\n"))
}
Expand Down
3 changes: 0 additions & 3 deletions R/phs_pal_name.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
phs_pal_name <- function(palette, type) {
# load the list phs_palette_types
phs_palette_types <- phsstyles::phs_palette_types

if (is.character(palette)) {
if (!palette %in% unlist(phs_palette_types)) {
warning("Unknown palette ", palette)
Expand Down
9 changes: 1 addition & 8 deletions R/phsstyles.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,5 @@
#' See the README on
#' \href{https://github.com/Public-Health-Scotland/phsstyles#readme}{GitHub}.
#'
#' @docType package
#' @name phsstyles
NULL

# Stops notes from appearing in R CMD check because of undefined global
# variables
if (getRversion() >= "2.15.1") utils::globalVariables(c("phs_colour_values",
"phs_palette_types",
"phs_palettes"))
"_PACKAGE"
Binary file removed data/phs_colour_values.rda
Binary file not shown.
Binary file removed data/phs_palette_types.rda
Binary file not shown.
Binary file removed data/phs_palettes.rda
Binary file not shown.
23 changes: 0 additions & 23 deletions man/phs_colour_values.Rd

This file was deleted.

Loading

0 comments on commit 3bba3e8

Please sign in to comment.