Skip to content

Commit

Permalink
R CMD CHECK passed
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryMcCartan committed Feb 23, 2021
1 parent d2360a0 commit 3309b20
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
^cover.jpg$
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export(wa_pal)
export(wacolors)
importFrom(ggplot2,discrete_scale)
importFrom(ggplot2,scale_color_gradientn)
importFrom(ggplot2,scale_fill_gradientn)
importFrom(grDevices,colorRampPalette)
importFrom(grDevices,rgb)
importFrom(graphics,image)
Expand Down
5 changes: 2 additions & 3 deletions R/codegen.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ pal_vector = function(palette, n, which=NULL,
#'
#' @param palette a `[wacolors]` palette or palette name.
#' @param which if not `NULL`, the indices or names of a subset of colors to use.
#' @param ... Other arguments passed on to [ggplot2::discrete_scale()],
#' [ggplot2::continuous_scale()], or [ggplot2::binned_scale()] to control
#' name, limits, breaks, labels and so forth.
#' @param type Either `continuous` or `discrete`. Use `continuous` if you want
#' to automatically interpolate between colors.
#' @param reverse `TRUE` if the colors should be reversed.
#'
#' @examples
Expand Down
8 changes: 7 additions & 1 deletion R/scales.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#' Helper function-palette for discrete scales
#'
#' @param pal the palette colors
#' @param reverse whether to reverse
#'
#' @importFrom grDevices colorRampPalette rgb
discr_pal = function(pal, reverse=FALSE) {
n_col = length(pal)
Expand All @@ -24,6 +28,8 @@ discr_pal = function(pal, reverse=FALSE) {
#' @param reverse `TRUE` if the colors should be reversed.
#'
#' @examples
#' library(ggplot2)
#'
#' ggplot(mtcars, aes(mpg, wt)) +
#' geom_point(aes(color = factor(cyl), size=hp)) +
#' scale_color_wa_d()
Expand All @@ -36,7 +42,7 @@ discr_pal = function(pal, reverse=FALSE) {
#' geom_bar(aes(x = cut, fill = clarity)) +
#' scale_fill_wa_d(wacolors$sound_sunset, reverse=TRUE)
#'
#' @importFrom ggplot2 discrete_scale scale_color_gradientn
#' @importFrom ggplot2 discrete_scale scale_color_gradientn scale_fill_gradientn
#' @export
scale_color_wa_d = function(palette="rainier", which=NULL, ..., reverse=FALSE) {
pal = match_pal(palette)
Expand Down
9 changes: 7 additions & 2 deletions R/util.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' Takes name of palette or palette itself and returns palette + name
#' @param name the name of the palette or the palette itself
match_pal = function(name) {
found_name = pmatch(name, names(wacolors))
if (!any(is.na(found_name))) {
Expand All @@ -17,8 +18,12 @@ match_pal = function(name) {

#' Create HTML code to view palette
#'
#' @param x the `palette` object
#' @param maxwidth the maximum width of the output, in CSS units
#' @param height the height width of the output, in CSS units
#'
#' @export
palette_html = function(x, maxwidth="30em", height="1em", ...) {
palette_html = function(x, maxwidth="30em", height="1em") {
n <- length(x)

cat('<div class="color-palette">',
Expand Down Expand Up @@ -84,7 +89,7 @@ pth = function(x) {

# Helper for interactive code output
code_output = function(x) {
if (interactive() && require("rstudioapi", quietly=TRUE)) {
if (interactive() && requireNamespace("rstudioapi", quietly=TRUE)) {
rstudioapi::sendToConsole(x, execute=F)
} else {
cat(x, "\n")
Expand Down
5 changes: 5 additions & 0 deletions man/discr_pal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/match_pal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions man/pal_functions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion man/palette_html.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/scale_wa.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3309b20

Please sign in to comment.