From 6f4507933bc2e2155bee269486a3fe82df0e3f47 Mon Sep 17 00:00:00 2001 From: Nan Xiao Date: Sun, 17 Mar 2024 19:15:12 -0400 Subject: [PATCH] Run `lintr::lint_package()` and fix linting issues --- R/continuous-gsea.R | 2 +- R/continuous-material.R | 2 +- R/discrete-aaas.R | 2 +- R/discrete-cosmic.R | 2 +- R/discrete-d3.R | 2 +- R/discrete-flatui.R | 2 +- R/discrete-frontiers.R | 2 +- R/discrete-futurama.R | 2 +- R/discrete-igv.R | 2 +- R/discrete-jama.R | 2 +- R/discrete-jco.R | 2 +- R/discrete-lancet.R | 2 +- R/discrete-locuszoom.R | 2 +- R/discrete-nejm.R | 2 +- R/discrete-npg.R | 2 +- R/discrete-rickandmorty.R | 2 +- R/discrete-simpsons.R | 2 +- R/discrete-startrek.R | 2 +- R/discrete-tron.R | 2 +- R/discrete-uchicago.R | 2 +- R/discrete-ucscgb.R | 2 +- data-raw/data-generator.R | 105 +++++++++++++++++++------------------- 22 files changed, 73 insertions(+), 74 deletions(-) diff --git a/R/continuous-gsea.R b/R/continuous-gsea.R index ce36615..5cf6640 100644 --- a/R/continuous-gsea.R +++ b/R/continuous-gsea.R @@ -29,7 +29,7 @@ rgb_gsea <- function(palette = c("default"), n = 12, alpha = 1, reverse = FALSE) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"gsea"[[palette]] func_cols <- colorRamp(raw_cols, space = "Lab", interpolate = "spline") diff --git a/R/continuous-material.R b/R/continuous-material.R index 723db86..7557e4c 100644 --- a/R/continuous-material.R +++ b/R/continuous-material.R @@ -54,7 +54,7 @@ rgb_material <- function( ), n = 10, alpha = 1, reverse = FALSE) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"material"[[palette]] func_cols <- colorRamp(raw_cols, space = "Lab", interpolate = "spline") diff --git a/R/discrete-aaas.R b/R/discrete-aaas.R index 02aa6a0..c339cd2 100644 --- a/R/discrete-aaas.R +++ b/R/discrete-aaas.R @@ -25,7 +25,7 @@ pal_aaas <- function(palette = c("default"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"aaas"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-cosmic.R b/R/discrete-cosmic.R index 645f8c6..dd75b7b 100644 --- a/R/discrete-cosmic.R +++ b/R/discrete-cosmic.R @@ -34,7 +34,7 @@ pal_cosmic <- function( alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"cosmic"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-d3.R b/R/discrete-d3.R index fc9e0e7..24848f0 100644 --- a/R/discrete-d3.R +++ b/R/discrete-d3.R @@ -30,7 +30,7 @@ pal_d3 <- function(palette = c("category10", "category20", "category20b", "category20c"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"d3"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-flatui.R b/R/discrete-flatui.R index ef5023c..bc59235 100644 --- a/R/discrete-flatui.R +++ b/R/discrete-flatui.R @@ -26,7 +26,7 @@ pal_flatui <- function(palette = c("default", "flattastic", "aussie"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"flatui"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-frontiers.R b/R/discrete-frontiers.R index 41bd766..2bcfea7 100644 --- a/R/discrete-frontiers.R +++ b/R/discrete-frontiers.R @@ -22,7 +22,7 @@ pal_frontiers <- function(palette = c("default"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"frontiers"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-futurama.R b/R/discrete-futurama.R index 11c3d4d..28e8426 100644 --- a/R/discrete-futurama.R +++ b/R/discrete-futurama.R @@ -23,7 +23,7 @@ pal_futurama <- function(palette = c("planetexpress"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"futurama"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-igv.R b/R/discrete-igv.R index 55f9c71..1bea09f 100644 --- a/R/discrete-igv.R +++ b/R/discrete-igv.R @@ -30,7 +30,7 @@ pal_igv <- function(palette = c("default", "alternating"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"igv"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-jama.R b/R/discrete-jama.R index 04a81ee..ea22566 100644 --- a/R/discrete-jama.R +++ b/R/discrete-jama.R @@ -24,7 +24,7 @@ pal_jama <- function(palette = c("default"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"jama"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-jco.R b/R/discrete-jco.R index 32b17d0..def588e 100644 --- a/R/discrete-jco.R +++ b/R/discrete-jco.R @@ -23,7 +23,7 @@ pal_jco <- function(palette = c("default"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"jco"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-lancet.R b/R/discrete-lancet.R index 226f6f9..f4bbee5 100644 --- a/R/discrete-lancet.R +++ b/R/discrete-lancet.R @@ -24,7 +24,7 @@ pal_lancet <- function(palette = c("lanonc"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"lancet"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-locuszoom.R b/R/discrete-locuszoom.R index 2c6760e..1479c3e 100644 --- a/R/discrete-locuszoom.R +++ b/R/discrete-locuszoom.R @@ -28,7 +28,7 @@ pal_locuszoom <- function(palette = c("default"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"locuszoom"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-nejm.R b/R/discrete-nejm.R index 68b7e1c..465ca41 100644 --- a/R/discrete-nejm.R +++ b/R/discrete-nejm.R @@ -24,7 +24,7 @@ pal_nejm <- function(palette = c("default"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"nejm"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-npg.R b/R/discrete-npg.R index 81da3dc..babca70 100644 --- a/R/discrete-npg.R +++ b/R/discrete-npg.R @@ -24,7 +24,7 @@ pal_npg <- function(palette = c("nrc"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"npg"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-rickandmorty.R b/R/discrete-rickandmorty.R index fe557b7..cd0c1c6 100644 --- a/R/discrete-rickandmorty.R +++ b/R/discrete-rickandmorty.R @@ -23,7 +23,7 @@ pal_rickandmorty <- function(palette = c("schwifty"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"rickandmorty"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-simpsons.R b/R/discrete-simpsons.R index 6470aad..1a78e79 100644 --- a/R/discrete-simpsons.R +++ b/R/discrete-simpsons.R @@ -23,7 +23,7 @@ pal_simpsons <- function(palette = c("springfield"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"simpsons"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-startrek.R b/R/discrete-startrek.R index 13a0e12..82ec4b4 100644 --- a/R/discrete-startrek.R +++ b/R/discrete-startrek.R @@ -23,7 +23,7 @@ pal_startrek <- function(palette = c("uniform"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"startrek"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-tron.R b/R/discrete-tron.R index 616dd75..65bd3cf 100644 --- a/R/discrete-tron.R +++ b/R/discrete-tron.R @@ -23,7 +23,7 @@ pal_tron <- function(palette = c("legacy"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"tron"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-uchicago.R b/R/discrete-uchicago.R index 8487869..1c144c3 100644 --- a/R/discrete-uchicago.R +++ b/R/discrete-uchicago.R @@ -28,7 +28,7 @@ pal_uchicago <- function(palette = c("default", "light", "dark"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"uchicago"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/R/discrete-ucscgb.R b/R/discrete-ucscgb.R index dc2b442..b0f7d08 100644 --- a/R/discrete-ucscgb.R +++ b/R/discrete-ucscgb.R @@ -23,7 +23,7 @@ pal_ucscgb <- function(palette = c("default"), alpha = 1) { palette <- match.arg(palette) - if (alpha > 1L | alpha <= 0L) stop("alpha must be in (0, 1]") + if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") raw_cols <- ggsci_db$"ucscgb"[[palette]] raw_cols_rgb <- col2rgb(raw_cols) diff --git a/data-raw/data-generator.R b/data-raw/data-generator.R index 7dafa2f..67e7a43 100644 --- a/data-raw/data-generator.R +++ b/data-raw/data-generator.R @@ -1,5 +1,4 @@ -# Generate internal color palettes data `R/sysdata.rda` -# +# Generate internal color palettes data `R/sysdata.rda`: # - R Packages - Internal data. # - Name that Color. @@ -477,54 +476,54 @@ ggsci_db$"material"$"blue-grey" <- c( save(ggsci_db, file = "R/sysdata.rda") -# test_barplot <- function(palette, type) { -# pal <- ggsci_db[[palette]][[type]] -# barplot(rep(1, length(pal)), col = pal) -# } -# -# test_barplot("npg", "nrc") -# test_barplot("aaas", "default") -# test_barplot("nejm", "default") -# test_barplot("lancet", "lanonc") -# test_barplot("jama", "default") -# test_barplot("jco", "default") -# test_barplot("ucscgb", "default") -# test_barplot("d3", "category10") -# test_barplot("d3", "category20") -# test_barplot("d3", "category20b") -# test_barplot("d3", "category20c") -# test_barplot("locuszoom", "default") -# test_barplot("igv", "default") -# test_barplot("igv", "alternating") -# test_barplot("uchicago", "default") -# test_barplot("uchicago", "light") -# test_barplot("uchicago", "dark") -# test_barplot("cosmic", "hallmarks_dark") -# test_barplot("cosmic", "hallmarks_light") -# test_barplot("cosmic", "signature_substitutions") -# test_barplot("startrek", "uniform") -# test_barplot("tron", "legacy") -# test_barplot("futurama", "planetexpress") -# test_barplot("rickandmorty", "schwifty") -# test_barplot("simpsons", "springfield") -# test_barplot("gsea", "default") -# test_barplot("flatuiau", "intense") -# test_barplot("material", "red") -# test_barplot("material", "pink") -# test_barplot("material", "purple") -# test_barplot("material", "deep-purple") -# test_barplot("material", "indigo") -# test_barplot("material", "blue") -# test_barplot("material", "light-blue") -# test_barplot("material", "cyan") -# test_barplot("material", "teal") -# test_barplot("material", "green") -# test_barplot("material", "light-green") -# test_barplot("material", "lime") -# test_barplot("material", "yellow") -# test_barplot("material", "amber") -# test_barplot("material", "orange") -# test_barplot("material", "deep-orange") -# test_barplot("material", "brown") -# test_barplot("material", "grey") -# test_barplot("material", "blue-grey") +test_barplot <- function(palette, type) { + pal <- ggsci_db[[palette]][[type]] + barplot(rep(1, length(pal)), col = pal) +} + +test_barplot("npg", "nrc") +test_barplot("aaas", "default") +test_barplot("nejm", "default") +test_barplot("lancet", "lanonc") +test_barplot("jama", "default") +test_barplot("jco", "default") +test_barplot("ucscgb", "default") +test_barplot("d3", "category10") +test_barplot("d3", "category20") +test_barplot("d3", "category20b") +test_barplot("d3", "category20c") +test_barplot("locuszoom", "default") +test_barplot("igv", "default") +test_barplot("igv", "alternating") +test_barplot("uchicago", "default") +test_barplot("uchicago", "light") +test_barplot("uchicago", "dark") +test_barplot("cosmic", "hallmarks_dark") +test_barplot("cosmic", "hallmarks_light") +test_barplot("cosmic", "signature_substitutions") +test_barplot("startrek", "uniform") +test_barplot("tron", "legacy") +test_barplot("futurama", "planetexpress") +test_barplot("rickandmorty", "schwifty") +test_barplot("simpsons", "springfield") +test_barplot("gsea", "default") +test_barplot("flatuiau", "intense") +test_barplot("material", "red") +test_barplot("material", "pink") +test_barplot("material", "purple") +test_barplot("material", "deep-purple") +test_barplot("material", "indigo") +test_barplot("material", "blue") +test_barplot("material", "light-blue") +test_barplot("material", "cyan") +test_barplot("material", "teal") +test_barplot("material", "green") +test_barplot("material", "light-green") +test_barplot("material", "lime") +test_barplot("material", "yellow") +test_barplot("material", "amber") +test_barplot("material", "orange") +test_barplot("material", "deep-orange") +test_barplot("material", "brown") +test_barplot("material", "grey") +test_barplot("material", "blue-grey")