Skip to content

Commit

Permalink
Run lintr::lint_package() and fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nanxstats committed Mar 17, 2024
1 parent 4aa3ecc commit 6f45079
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 74 deletions.
2 changes: 1 addition & 1 deletion R/continuous-gsea.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion R/continuous-material.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-aaas.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-cosmic.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-d3.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-flatui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-frontiers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-futurama.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-igv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-jama.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-jco.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-lancet.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-locuszoom.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-nejm.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-npg.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-rickandmorty.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-simpsons.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-startrek.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-tron.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-uchicago.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/discrete-ucscgb.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
105 changes: 52 additions & 53 deletions data-raw/data-generator.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Generate internal color palettes data `R/sysdata.rda`
#
# Generate internal color palettes data `R/sysdata.rda`:
# - R Packages - Internal data. <https://r-pkgs.org/data.html#sec-data-sysdata>
# - Name that Color. <http://chir.ag/projects/name-that-color/>

Expand Down Expand Up @@ -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")

0 comments on commit 6f45079

Please sign in to comment.