Skip to content

Conversation

@ANAMASGARD
Copy link
Contributor

@ANAMASGARD ANAMASGARD commented Dec 21, 2025

FIXES #168

What's broken

viz <- list(
  plot = ggplot() + 
    facet_wrap(. ~ Species) +  # formula notation
    geom_point(aes(x, y), data = iris)
)
animint2dir(viz) 
  • Current error:
    Error: At least one layer must contain all variables used for facetting

Doesn't tell you what's wrong or how to fix it.

  • Workaround that works:
    facet_wrap("Species") # string notation works fine

What I am fixing

  1. Detect when formula notation is used in facets
  2. Give clear error telling user to use string notation instead
  3. Fix happens in animint2dir() - animint2-specific code only

Next commit will add the fix to make tests pass.

Issue #168 - facet_wrap(. ~ var) gives unhelpful error when var is missing.

Added tests that will pass once we improve error messages in animint2dir().
Tests cover facet_wrap and facet_grid with missing variables.

These tests are animint2-specific .
When facet_wrap or facet_grid uses formula notation with a variable
that does not exist in the data, the error now shows:
- Which variable is missing
- What columns are available
- Suggests using string notation instead

Fixes #168
@ANAMASGARD
Copy link
Contributor Author

ANAMASGARD commented Dec 22, 2025

Before :-

Error: At least one layer must contain all variables used for facetting

After :-

Error: Facet variable not found in data: MissingVar
Available columns: Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species
Use string notation like facet_wrap("var") instead of formula notation facet_wrap(. ~ var) ```

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.66%. Comparing base (68b074e) to head (2472155).

Files with missing lines Patch % Lines
R/z_animintHelpers.R 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #285      +/-   ##
==========================================
- Coverage   73.06%   69.66%   -3.40%     
==========================================
  Files         164      163       -1     
  Lines        8758     6033    -2725     
==========================================
- Hits         6399     4203    -2196     
+ Misses       2359     1830     -529     
Flag Coverage Δ
javascript ?
r 69.66% <96.55%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tdhock
Copy link
Collaborator

tdhock commented Dec 22, 2025

No obvious timing issues in HEAD=fix-168-facet-error-message
Comparison Plot

Generated via commit 2472155

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 4 minutes and 53 seconds
Installing different package versions 58 seconds
Running and plotting the test cases 3 minutes and 30 seconds

@ANAMASGARD
Copy link
Contributor Author

Sir @tdhock The 2 failing tests in JS_coverage are in test-compiler-ghpages.R (GitHub Pages tests), not related to this PR. This is the same race condition issue where parallel CI jobs conflict over the shared test repository.

All facet-related tests pass:

  • R_coverage: 2096+ tests passed
  • CRAN: passed
  • My 3 new facet error message tests pass

The fix is working correctly. Please review and give your feedback Sir .

@ANAMASGARD ANAMASGARD requested a review from tdhock December 22, 2025 10:04
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.

facet_wrap ~var errors but "var" works

3 participants