Skip to content

Commit

Permalink
updated deprecated ggplot2::aes_string() to ggplot2::aes()
Browse files Browse the repository at this point in the history
  • Loading branch information
dunkenwg committed Sep 12, 2024
1 parent 2f890dd commit 581a862
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion R/plot-biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ypr_plot_biomass <- function(population, y = "Biomass", color = NULL) {
ggplot2::waiver()
}

ggplot2::ggplot(data = biomass, ggplot2::aes_string(x = "Age", weight = y)) +
ggplot2::ggplot(data = biomass, ggplot2::aes(x = Age, weight = .data[[y]])) +
(if (is.null(color)) {
ggplot2::geom_bar(width = 1)
} else {
Expand Down
4 changes: 2 additions & 2 deletions R/plot-fish.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ ypr_plot_fish <- function(population, x = "Age", y = "Survivors",

gp <- ggplot2::ggplot(data = fish) +
(if (length(unique(fish$Ecotype)) == 1) {
ggplot2::aes_string(x = x, weight = y)
ggplot2::aes(x = .data[[x]], weight = .data[[y]])
} else {
ggplot2::aes_string(x = x, weight = y, fill = "Ecotype")
ggplot2::aes(x = .data[[x]], weight = .data[[y]], fill = Ecotype)
}) +
(if (is.null(color)) {
ggplot2::geom_bar(width = binwidth)
Expand Down
2 changes: 1 addition & 1 deletion R/plot-schedule.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ypr_plot_schedule <- function(population, x = "Age", y = "Length") {
group <- if (ecotype) "Ecotype" else NULL
color <- if (ecotype) "Ecotype" else NULL

ggplot2::ggplot(data = schedule, ggplot2::aes_string(x = x, y = y, group = group, color = color)) +
ggplot2::ggplot(data = schedule, ggplot2::aes(x = .data[[x]], y = .data[[y]], group = group, color = color)) +
ggplot2::geom_line() +
ggplot2::scale_y_continuous(y, labels = labels) +
ggplot2::expand_limits(x = 0, y = 0)
Expand Down
12 changes: 6 additions & 6 deletions R/plot-sr.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ ypr_plot_sr <- function(population,

ggplot2::ggplot(
data = data,
ggplot2::aes_string(
x = "Eggs",
y = "Recruits"
ggplot2::aes(
x = Eggs,
y = Recruits
)
) +
(
if (plot_values) {
ggplot2::geom_path(
data = data2,
ggplot2::aes_string(
group = "Type",
color = "Type"
ggplot2::aes(
group = Type,
color = Type
),
linetype = "dotted"
)
Expand Down
18 changes: 9 additions & 9 deletions R/plot-yield.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' plot_values = FALSE
#' ) +
#' ggplot2::facet_wrap(~Llo) +
#' ggplot2::aes_string(group = "Rk", color = "Rk") +
#' ggplot2::aes(group = Rk, color = Rk) +
#' ggplot2::scale_color_manual(values = c("black", "blue"))
#'
#' ypr_plot_yield(ypr_populations(Rk = c(2.5, 4.6), Llo = c(0, 60))) +
Expand Down Expand Up @@ -86,15 +86,15 @@ ypr_plot_yield.default <- function(object,
xlab <- if (u) "Exploitation Probability (%)" else "Capture Probability (%)"
x <- if (u) "u" else "pi"

ggplot2::ggplot(data = data, ggplot2::aes_string(x = x, y = y)) +
ggplot2::ggplot(data = data, ggplot2::aes(x = .data[[x]], y = .data[[y]])) +
(
if (plot_values) {
list(
ggplot2::geom_path(
data = data2,
ggplot2::aes_string(
group = "Type",
color = "Type"
ggplot2::aes(
group = Type,
color = Type
),
linetype = "dotted"
),
Expand Down Expand Up @@ -165,15 +165,15 @@ ypr_plot_yield.ypr_populations <- function(object,
xlab <- if (u) "Exploitation Probability (%)" else "Capture Probability (%)"
x <- if (u) "u" else "pi"

ggplot2::ggplot(data = data, ggplot2::aes_string(x = x, y = y)) +
ggplot2::ggplot(data = data, ggplot2::aes(x = .data[[x]], y = .data[[y]])) +
(
if (plot_values) {
list(
ggplot2::geom_path(
data = data2,
ggplot2::aes_string(
group = "Type",
color = "Type"
ggplot2::aes(
group = Type,
color = Type
),
linetype = "dotted"
),
Expand Down
Binary file modified tests/testthat/_snaps/plot-schedule/ypr_plot_schedule2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/testthat/test-plot-yield.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_that("ypr_plot_yield2", {
pi = seq(0, 1, length.out = 2), plot_values = FALSE
) +
ggplot2::facet_wrap(~Llo) +
ggplot2::aes_string(group = "Rk", color = "Rk") +
ggplot2::aes(group = Rk, color = Rk) +
ggplot2::scale_color_manual(values = c("black", "blue"))

expect_snapshot_plot(gp, "ypr_plot_yield2")
Expand Down

0 comments on commit 581a862

Please sign in to comment.