Skip to content

Commit

Permalink
Add R 4.2 dependency, remove magrittr and add lineribbon test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhodge931 committed Dec 2, 2024
1 parent a4e238b commit ecac560
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 83 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ URL: https://davidhodge931.github.io/ggblanket/,
https://github.com/davidhodge931/ggblanket
BugReports: https://github.com/davidhodge931/ggblanket/issues
Depends:
R (>= 4.2.0)
R (>= 4.2.0)
Imports:
colorspace,
dplyr (>= 1.0.4),
Expand All @@ -23,7 +23,6 @@ Imports:
hms (>= 0.5.0),
labelled,
lubridate (>= 1.7.8),
magrittr,
purrr,
rlang (>= 1.1.0),
scales (>= 1.3.0),
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(aes_colour_contrast)
export(blue)
export(dark_mode_b)
Expand Down Expand Up @@ -67,7 +66,6 @@ export(weave_col_palettes)
export(weave_geom_defaults)
export(weave_mode)
export(weave_theme)
importFrom(magrittr,"%>%")
importFrom(rlang,"!!!")
importFrom(rlang,"!!")
importFrom(rlang,.data)
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# ggblanket 11.0.0.9000

* Deprecated `aes_colour_darken`, `aes_colour_lighten`, `aes_fill_darken` and `aes_colour_lighten`.
* Changed `gg_smooth` and `gg_ribbon` alpha default to NA.
* Added R 4.2.0 dependency.
* Removed `aes_colour_darken`, `aes_colour_lighten`, `aes_fill_darken` and `aes_colour_lighten`.
* Removed `gg_ribbon` alpha default, and changed `gg_smooth` to NA.
* Added colour blending (e.g. `blend = "multiply`).
* Added `gg_lineribbon`.

Expand Down
16 changes: 8 additions & 8 deletions R/get_base.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ get_base <- function(

if (rlang::quo_is_null(x) & !rlang::quo_is_null(y)) {
if (rlang::quo_is_null(col)) {
plot <- data %>%
plot <- data |>
ggplot2::ggplot(mapping = ggplot2::aes(
y = !!y,
xmin = !!xmin,
Expand All @@ -63,7 +63,7 @@ get_base <- function(
))
}
else if (!rlang::quo_is_null(col)) {
plot <- data %>%
plot <- data |>
ggplot2::ggplot(mapping = ggplot2::aes(
y = !!y,
col = !!col,
Expand All @@ -85,7 +85,7 @@ get_base <- function(
}
else if (!rlang::quo_is_null(x) & rlang::quo_is_null(y)) {
if (rlang::quo_is_null(col)) {
plot <- data %>%
plot <- data |>
ggplot2::ggplot(mapping = ggplot2::aes(
x = !!x,
xmin = !!xmin,
Expand All @@ -103,7 +103,7 @@ get_base <- function(
))
}
else if (!rlang::quo_is_null(col)) {
plot <- data %>%
plot <- data |>
ggplot2::ggplot(mapping = ggplot2::aes(
x = !!x,
col = !!col,
Expand All @@ -125,7 +125,7 @@ get_base <- function(
}
else if (!rlang::quo_is_null(x) & !rlang::quo_is_null(y)) {
if (rlang::quo_is_null(col)) {
plot <- data %>%
plot <- data |>
ggplot2::ggplot(mapping = ggplot2::aes(
x = !!x,
y = !!y,
Expand All @@ -144,7 +144,7 @@ get_base <- function(
))
}
else if (!rlang::quo_is_null(col)) {
plot <- data %>%
plot <- data |>
ggplot2::ggplot(mapping = ggplot2::aes(
x = !!x,
y = !!y,
Expand All @@ -167,7 +167,7 @@ get_base <- function(
}
else if (rlang::quo_is_null(x) & rlang::quo_is_null(y)) {
if (rlang::quo_is_null(col)) {
plot <- data %>%
plot <- data |>
ggplot2::ggplot(mapping = ggplot2::aes(
xmin = !!xmin,
xmax = !!xmax,
Expand All @@ -184,7 +184,7 @@ get_base <- function(
))
}
else if (!rlang::quo_is_null(col)) {
plot <- data %>%
plot <- data |>
ggplot2::ggplot(mapping = ggplot2::aes(
col = !!col,
fill = !!col,
Expand Down
44 changes: 22 additions & 22 deletions R/gg_blanket.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#'
#' set_blanket()
#'
#' penguins %>%
#' penguins |>
#' gg_blanket(
#' geom = "violin",
#' stat = "ydensity",
Expand Down Expand Up @@ -374,23 +374,23 @@ gg_blanket <- function(data = NULL,
# process the data
##############################################################################

data <- data %>%
data <- data |>
#ungroup the data
dplyr::ungroup() %>%
dplyr::ungroup() |>
#convert to factors class that can handle labels
dplyr::mutate(dplyr::across(c(!!x, !!xmin, !!xmax, !!xend,
!!y, !!ymin, !!ymax, !!yend,
!!col, !!facet, !!facet2) &
(tidyselect::where(is.character) | tidyselect::where(is.factor) | tidyselect::where(is.logical)),
function(x) labelled::to_factor(x))) %>%
function(x) labelled::to_factor(x))) |>
#reverse y*, so that reads top low-levels to bottom high-levels
dplyr::mutate(dplyr::across(c(!!y, !!ymin, !!ymax, !!yend) &
tidyselect::where(is.factor),
function(x) forcats::fct_rev(x)))

#if flipped, order col correctly
if ((!identical(rlang::eval_tidy(y, data), rlang::eval_tidy(col, data))) & x_symmetric) {
data <- data %>%
data <- data |>
dplyr::mutate(dplyr::across(!!col & tidyselect::where(is.factor),
function(x) forcats::fct_rev(x)))
}
Expand Down Expand Up @@ -729,11 +729,11 @@ gg_blanket <- function(data = NULL,

#make a tidy name to deal with composed transforms
if (inherits(col_transform, what = "transform")) {
col_transform <- col_transform$name %>%
stringr::str_remove("composition") %>%
stringr::str_remove("\\(") %>%
stringr::str_remove("\\)") %>%
stringr::str_split(",") %>%
col_transform <- col_transform$name |>
stringr::str_remove("composition") |>
stringr::str_remove("\\(") |>
stringr::str_remove("\\)") |>
stringr::str_split(",") |>
unlist()
}

Expand Down Expand Up @@ -810,23 +810,23 @@ gg_blanket <- function(data = NULL,
}
} else col_n_factor <- NA

colour_distinct <- plot_data %>%
dplyr::select(tidyselect::any_of("colour")) %>%
colour_distinct <- plot_data |>
dplyr::select(tidyselect::any_of("colour")) |>
dplyr::distinct()

if (ncol(colour_distinct) > 0) {
colour_n <- colour_distinct %>%
colour_n <- colour_distinct |>
dplyr::filter(.data$colour != "grey50") |>
dplyr::count() |>
dplyr::pull()
} else colour_n <- 1

fill_distinct <- plot_data %>%
dplyr::select(tidyselect::any_of("fill")) %>%
fill_distinct <- plot_data |>
dplyr::select(tidyselect::any_of("fill")) |>
dplyr::distinct()

if (ncol(fill_distinct) > 0) {
fill_n <- fill_distinct %>%
fill_n <- fill_distinct |>
dplyr::filter(.data$fill != "grey50") |>
dplyr::count() |>
dplyr::pull()
Expand Down Expand Up @@ -1160,9 +1160,9 @@ gg_blanket <- function(data = NULL,
}

if (x_symmetric) {
data_x <- plot_data %>%
dplyr::select(tidyselect::matches(stringr::regex("^(?!xid|xbin)x.*"))) %>%
tidyr::pivot_longer(cols = tidyselect::everything(), values_to = "x") %>%
data_x <- plot_data |>
dplyr::select(tidyselect::matches(stringr::regex("^(?!xid|xbin)x.*"))) |>
tidyr::pivot_longer(cols = tidyselect::everything(), values_to = "x") |>
dplyr::filter(!is.na(.data$x))

plot <- plot +
Expand Down Expand Up @@ -1225,9 +1225,9 @@ gg_blanket <- function(data = NULL,
}

if (y_symmetric) {
data_y <- plot_data %>%
dplyr::select(tidyselect::matches(stringr::regex("^(?!yid|ybin)y.*"))) %>%
tidyr::pivot_longer(cols = tidyselect::everything(), values_to = "y") %>%
data_y <- plot_data |>
dplyr::select(tidyselect::matches(stringr::regex("^(?!yid|ybin)y.*"))) |>
tidyr::pivot_longer(cols = tidyselect::everything(), values_to = "y") |>
dplyr::filter(!is.na(.data$y))

plot <- plot +
Expand Down
1 change: 1 addition & 0 deletions R/gg_smooth.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#' x = flipper_length_mm,
#' y = body_mass_g,
#' col = species,
#' se = TRUE,
#' blend = "multiply",
#' )
#'
Expand Down
24 changes: 12 additions & 12 deletions R/scale_symmetric.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ scale_x_symmetric <- function(...,

if (is.character(transform)) transform_name <- transform
else if (inherits(transform, what = "transform")) {
transform_name <- transform$name %>%
stringr::str_remove("composition") %>%
stringr::str_remove("\\(") %>%
stringr::str_remove("\\)") %>%
stringr::str_split(",") %>%
transform_name <- transform$name |>
stringr::str_remove("composition") |>
stringr::str_remove("\\(") |>
stringr::str_remove("\\)") |>
stringr::str_split(",") |>
unlist()
}

Expand All @@ -52,7 +52,7 @@ scale_x_symmetric <- function(...,
if (symmetric) {
x <- rlang::enquo(x)

vctr <- data %>%
vctr <- data |>
dplyr::pull(!!x)

if (!rlang::is_null(expand_limits)) {
Expand Down Expand Up @@ -176,11 +176,11 @@ scale_y_symmetric <- function(...,

if (is.character(transform)) transform_name <- transform
else if (inherits(transform, what = "transform")) {
transform_name <- transform$name %>%
stringr::str_remove("composition") %>%
stringr::str_remove("\\(") %>%
stringr::str_remove("\\)") %>%
stringr::str_split(",") %>%
transform_name <- transform$name |>
stringr::str_remove("composition") |>
stringr::str_remove("\\(") |>
stringr::str_remove("\\)") |>
stringr::str_split(",") |>
unlist()
}

Expand All @@ -197,7 +197,7 @@ scale_y_symmetric <- function(...,
if (symmetric) {
y <- rlang::enquo(y)

vctr <- data %>%
vctr <- data |>
dplyr::pull(!!y)

if (!rlang::is_null(expand_limits)) {
Expand Down
14 changes: 0 additions & 14 deletions R/utils-pipe.R

This file was deleted.

2 changes: 1 addition & 1 deletion man/gg_blanket.Rd

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

1 change: 1 addition & 0 deletions man/gg_smooth.Rd

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

20 changes: 0 additions & 20 deletions man/pipe.Rd

This file was deleted.

Loading

0 comments on commit ecac560

Please sign in to comment.