Skip to content

Fix ggplot2 deprecation warnings (aes_string, size for lines)#53

Merged
arcaldwell49 merged 3 commits intomasterfrom
copilot/fix-4f8638e5-b604-44c5-9ec1-086ebb667602
Oct 3, 2025
Merged

Fix ggplot2 deprecation warnings (aes_string, size for lines)#53
arcaldwell49 merged 3 commits intomasterfrom
copilot/fix-4f8638e5-b604-44c5-9ec1-086ebb667602

Conversation

Copy link
Contributor

Copilot AI commented Oct 2, 2025

Problem

Calling Superpower::ANOVA_design() and other plotting functions produced ggplot2 lifecycle warnings about deprecated APIs:

  1. aes_string() (deprecated since ggplot2 3.0.0)
  2. size aesthetic for lines (deprecated since ggplot2 3.4.0; replaced by linewidth)

Example warning:

Warning: `aes_string()` was deprecated in ggplot2 3.0.0.Please use tidy evaluation idioms with `aes()`.

Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.Please use `linewidth` instead.

Solution

1. Replaced aes_string() with aes() using tidy evaluation

Before:

ggplot(dataframe_means, aes_string(y = "mu", x = factornames[1]))

After:

ggplot(dataframe_means, aes(y = .data[["mu"]], x = .data[[factornames[1]]]))

The .data[[]] pronoun is the recommended approach for programmatic column selection with ggplot2's tidy evaluation system.

2. Replaced size with linewidth for line geometries

Before:

geom_errorbar(..., size = .6, ...)
geom_line(size = 1.5)

After:

geom_errorbar(..., linewidth = .6, ...)
geom_line(linewidth = 1.5)

Files Modified

  • R/ANOVA_design.R - Fixed aes_string() and geom_errorbar() size
  • R/ANOVA_exact.R - Fixed aes_string()
  • R/plot_power.R - Fixed geom_line() size
  • R/minimize_balance_alpha.R - Fixed geom_line() size

Impact

  • ✅ Eliminates all ggplot2 deprecation warnings
  • ✅ No behavior changes - plots remain identical
  • ✅ Compatible with current and future ggplot2 versions
  • ✅ Minimal, surgical changes to codebase

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>ANOVA_design() triggers ggplot2 deprecation warnings (aes_string, size for lines)</issue_title>
<issue_description>### Description

Calling Superpower::ANOVA_design() produces ggplot2 lifecycle warnings about use of deprecated APIs:

  • aes_string() (deprecated since ggplot2 3.0.0; use tidy-eval with aes()), and

  • size aesthetic for lines (deprecated since ggplot2 3.4.0; use linewidth).

The warnings indicate that the deprecated features are used inside Superpower.

Minimal reproducible example

set.seed(123)
library(Superpower)
library(ggplot2)

design_result <- ANOVA_design(
  design      = "2b*2w",
  n           = 20,
  mu          = c(0, 0, 0, 0),
  sd          = 1,
  r           = 0.5,
  labelnames  = c("condition","A","B","time","pre","post")
)

What I expected

No ggplot2 deprecation warnings during design creation/plotting.

What actually happened

1: aes_string()` was deprecated in ggplot2 3.0.0.Please use tidy evaluation idioms with `aes()`.See also `vignette("ggplot2-in-packages")` for more information.The deprecated feature was likely used in the Superpower package.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings() to see where this warning was generated.```

2: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.Please use `linewidth` instead.The deprecated feature was likely used in the Superpower package.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.

Lifecycle trace (from lifecycle::last_lifecycle_warnings())

 2.   └─Superpower::ANOVA_design(...) 
 3.     ├─ggplot2::ggplot(...)
 4.     ├─ggplot2:::ggplot.default(...)
 5.     │ └─ggplot2:::validate_mapping(mapping)
 6.     │   └─S7::S7_inherits(mapping)
 7.     └─ggplot2::aes_string(y = "mu", x = factornames[1], colour = factornames[2])
 8.       └─ggplot2:::deprecate_warn0(...)

Environment

> R.version.string
[1] "R version 4.5.1 (2025-06-13 ucrt)"
> packageVersion("Superpower")   
[1] ‘0.2.4.1> packageVersion("ggplot2")      
[1] ‘4.0.0> packageVersion("lifecycle") 
[1] ‘1.0.4> sessioninfo::session_info() 
─ Session info ─────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.1 (2025-06-13 ucrt)
 os       Windows 10 x64 (build 19045)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_Jamaica.utf8
 ctype    English_Jamaica.utf8
 tz       Africa/Cairo
 date     2025-10-03
 rstudio  2025.09.1+401 Cucumberleaf Sunflower (desktop)
 pandoc   3.2 @ C:\\PROGRA~1\\Pandoc\\pandoc.exe
```</issue_description>

<agent_instructions>check for deprecation issues with ggplot2, in particular the warning related to size aesthetic for lines</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>
Fixes #52

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 2, 2025 21:57
…and size with linewidth

Co-authored-by: arcaldwell49 <24322628+arcaldwell49@users.noreply.github.com>
…imize_balance_alpha

Co-authored-by: arcaldwell49 <24322628+arcaldwell49@users.noreply.github.com>
Copilot AI changed the title [WIP] ANOVA_design() triggers ggplot2 deprecation warnings (aes_string, size for lines) Fix ggplot2 deprecation warnings (aes_string, size for lines) Oct 2, 2025
Copilot AI requested a review from arcaldwell49 October 2, 2025 22:04
@arcaldwell49 arcaldwell49 marked this pull request as ready for review October 3, 2025 14:06
Copilot AI review requested due to automatic review settings October 3, 2025 14:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes ggplot2 deprecation warnings by updating deprecated API usage in the Superpower package. The changes address two main deprecation issues: replacing aes_string() with tidy evaluation using aes() and .data[[]], and replacing the deprecated size parameter with linewidth for line geometries.

  • Replaced aes_string() with aes() using .data[[]] pronoun for tidy evaluation
  • Updated geom_line() and geom_errorbar() to use linewidth instead of deprecated size parameter

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
R/ANOVA_design.R Updated aes_string() calls and geom_errorbar() size parameter
R/ANOVA_exact.R Replaced aes_string() with tidy evaluation syntax
R/plot_power.R Changed geom_line() size parameter to linewidth
R/minimize_balance_alpha.R Updated geom_line() size parameter to linewidth

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@arcaldwell49 arcaldwell49 merged commit 46d1dbc into master Oct 3, 2025
10 checks passed
@arcaldwell49 arcaldwell49 deleted the copilot/fix-4f8638e5-b604-44c5-9ec1-086ebb667602 branch October 3, 2025 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANOVA_design() triggers ggplot2 deprecation warnings (aes_string, size for lines)

3 participants