-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b612c6
commit cba1f7a
Showing
21 changed files
with
442 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
^README\.Rmd$ | ||
^\.github$ | ||
^codecov\.yml$ | ||
^data-raw$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: R-CMD-check | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ${{ matrix.config.os }} | ||
|
||
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- {os: macos-latest, r: 'release'} | ||
- {os: windows-latest, r: 'release'} | ||
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} | ||
- {os: ubuntu-latest, r: 'release'} | ||
- {os: ubuntu-latest, r: 'oldrel-1'} | ||
|
||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
r-version: ${{ matrix.config.r }} | ||
http-user-agent: ${{ matrix.config.http-user-agent }} | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::rcmdcheck | ||
needs: check | ||
|
||
- uses: r-lib/actions/check-r-package@v2 | ||
with: | ||
upload-snapshots: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: test-coverage | ||
|
||
jobs: | ||
test-coverage: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::covr | ||
needs: coverage | ||
|
||
- name: Test coverage | ||
run: | | ||
covr::codecov( | ||
quiet = FALSE, | ||
clean = FALSE, | ||
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") | ||
) | ||
shell: Rscript {0} | ||
|
||
- name: Show testthat output | ||
if: always() | ||
run: | | ||
## -------------------------------------------------------------------- | ||
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true | ||
shell: bash | ||
|
||
- name: Upload test results | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-test-failures | ||
path: ${{ runner.temp }}/package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: oxfordtheme | ||
Type: Package | ||
Title: University of Oxford Theme and Theme Components for 'ggplot2' | ||
Title: Oxford Theme and Theme Components | ||
Version: 0.0.0.9000 | ||
Authors@R: person( | ||
given = "Ernest", | ||
|
@@ -9,10 +9,17 @@ Authors@R: person( | |
email = "[email protected]", | ||
role = c("aut", "cre") | ||
) | ||
Description: Theme and theme components for 'ggplot2' based on University of | ||
Oxford's visual identity guidelines | ||
Description: Theme and theme components based on University of Oxford's visual | ||
identity guidelines | ||
<https://www.ox.ac.uk/sites/files/oxford/media_wysiwyg/Oxford%20Blue%20LR.pdf>. | ||
License: GPL (>= 3) | ||
Depends: | ||
R (>= 2.10) | ||
Imports: | ||
stringr | ||
Suggests: | ||
covr | ||
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 7.2.3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(cmyk2rgb) | ||
export(oxford_palettes) | ||
importFrom(grDevices,col2rgb) | ||
importFrom(stringr,str_pad) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#' | ||
#' Oxford colours based on University of Oxford's visual identity guidelines | ||
#' | ||
#' @format A data frame with 5 columns and 34 rows: | ||
#' | ||
#' | **Variable** | **Description** | | ||
#' | :--- | :--- | | ||
#' | *name* | Official Oxford colour name | | ||
#' | *rgb* | Three integers for the red, green, blue components of the RGB colour model | | ||
#' | *cmyk* | Four integers for the cyan, magenta, yellow, and black components of the CMYK colour model | | ||
#' | *hex* | Hexadecimal codes for corresponding colour | | ||
#' | *pantone* | Pantone colour name | | ||
#' | ||
#' @examples | ||
#' oxford_colours | ||
#' | ||
#' @source https://communications.web.ox.ac.uk/communications-resources/visual-identity/identity-guidelines/colours | ||
#' | ||
"oxford_colours" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' | ||
#' Get named Oxford colours vector | ||
#' | ||
#' @param df The `oxford_colours` data.frame. | ||
#' @param type A character vector of colour type. Can be "rgb", "cmyk", "hex", | ||
#' or "pantone". Default is "hex". | ||
#' @param pattern Optional. A character value or vector to use as a search term. | ||
#' Default is NULL. | ||
#' | ||
#' @return A named vector of Oxford colour/s | ||
#' | ||
#' @examples | ||
#' get_oxford_colours() | ||
#' get_oxford_colours(type = "rgb") | ||
#' get_oxford_colours(pattern = "lilac") | ||
#' | ||
#' @export | ||
#' | ||
get_oxford_colours <- function(pattern = NULL, | ||
df = oxford_colours, | ||
type = c("hex", "rgb", "cmyk", "pantone")){ | ||
## Get type ---- | ||
type <- match.arg(type) | ||
|
||
## Determine if there is something specific to search for ---- | ||
if (!is.null(pattern)) { | ||
pattern <- paste(pattern, collapse = "|") | ||
## Get colours vector ---- | ||
ox_cols <- df[stringr::str_detect(df$name, pattern = pattern,), c("name", type)] |> | ||
(\(x) | ||
{ | ||
cols <- x[[type]] | ||
names(cols) <- x[["name"]] | ||
cols | ||
} | ||
)() | ||
} else { | ||
## Get colours vector ---- | ||
ox_cols <- df[ , c("name", type)] |> | ||
(\(x) | ||
{ | ||
cols <- x[[type]] | ||
names(cols) <- x[["name"]] | ||
cols | ||
} | ||
)() | ||
} | ||
|
||
ox_cols | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#' | ||
#' Complete list of Oxford colour palettes | ||
#' | ||
#' @export | ||
#' | ||
oxford_palettes <- list( | ||
blues = c("#4891DC", "#9ECEEB", "#44687D", "#5F9BAF", "#A1C4D0", "#007770", "#7BA296", "#BCD2C3"), | ||
greens = c("#69913B", "#B9CF96", "#CEDBAF", "#AAB300", "#DBDE72", "#E3E597"), | ||
oranges = c("#CF7A30", "#F5CF47", "#F3DE74"), | ||
reds = c("#872434", "#BE0F34", "#EBC4CB"), | ||
grays = c("#A79D96", "#C7C2BC", "#E0DED9"), | ||
heritage = get_oxford_colours(pattern = c("sienna", "peach", "pink", "sage green", "Oxford green", "Oxford blue")) | ||
) | ||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#' | ||
#' Oxford Theme and Theme Components | ||
#' | ||
#' Theme and theme components for 'ggplot2' based on University of Oxford's | ||
#' visual identity guidelines | ||
#' <https://www.ox.ac.uk/sites/files/oxford/media_wysiwyg/Oxford%20Blue%20LR.pdf>. | ||
#' | ||
#' | ||
#' @md | ||
#' @name oxfordtheme | ||
#' @docType package | ||
#' @author Ernest Guevarra ([email protected]) | ||
#' @keywords internal | ||
#' @importFrom stringr str_pad | ||
#' @importFrom grDevices col2rgb | ||
#' | ||
"_PACKAGE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#' | ||
#' Convert CMYK to RGB | ||
#' | ||
#' @param C An integer value for cyan | ||
#' @param Y An integer value for yellow | ||
#' @param M An integer value for magenta | ||
#' @param K An integer value for key (black) | ||
#' | ||
#' @return A named vector for R, G, and B for RGB | ||
#' | ||
#' @examples | ||
#' cmyk2rgb(100, 80, 0, 60) | ||
#' | ||
#' @export | ||
#' | ||
cmyk2rgb <- function(C, M, Y, K) { | ||
C <- C / 100.0 | ||
M <- M / 100.0 | ||
Y <- Y / 100.0 | ||
K <- K / 100.0 | ||
|
||
n.c <- (C * (1 - K) + K) | ||
n.m <- (M * (1 - K) + K) | ||
n.y <- (Y * (1 - K) + K) | ||
|
||
r.col <- ceiling(255 * (1 - n.c)) | ||
g.col <- ceiling(255 * (1 - n.m)) | ||
b.col <- ceiling(255 * (1 - n.y)) | ||
|
||
paste0( | ||
"#", | ||
stringr::str_pad(as.hexmode(r.col), width = 2, side = "left", pad = "0"), | ||
stringr::str_pad(as.hexmode(g.col), width = 2, side = "left", pad = "0"), | ||
stringr::str_pad(as.hexmode(b.col), width = 2, side = "left", pad = "0") | ||
) |> | ||
grDevices::col2rgb() |> | ||
(\(x) c(R = x[1], G = x[2], B = x[3]))() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
comment: false | ||
|
||
coverage: | ||
status: | ||
project: | ||
default: | ||
target: auto | ||
threshold: 1% | ||
informational: true | ||
patch: | ||
default: | ||
target: auto | ||
threshold: 1% | ||
informational: true |
Oops, something went wrong.