Skip to content

Fix density plot error by using correct bandwidth string in BuildPlots.R #2809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AtomChen0425
Copy link

Summary

This PR fixes a bug in BuildPlots.R where the use of an incorrect bandwidth string in geom_density() caused runtime errors when generating density plots.

Changes

  • Replaced bw = "SJ" with bw = "sj" in all geom_density() calls:
    • Line 108
    • Line 121
    • Line 158

Problem

The original code used bw = "SJ" (uppercase), which is not a valid option for the bw parameter in geom_density(). This caused the following error:

2: Computation failed in `stat_density()`.
Caused by error in `precompute_bw()`:
! `bw` must be one of "nrd0", "nrd", "ucv", "bcv", "sj", "sj-ste", or
  "sj-dpi", not "SJ".
ℹ Did you mean "sj"? 
3: Computation failed in `stat_density()`.
Caused by error in `precompute_bw()`:
! `bw` must be one of "nrd0", "nrd", "ucv", "bcv", "sj", "sj-ste", or
  "sj-dpi", not "SJ".
ℹ Did you mean "sj"? 
4: Computation failed in `stat_density()`.
Caused by error in `precompute_bw()`:
! `bw` must be one of "nrd0", "nrd", "ucv", "bcv", "sj", "sj-ste", or
  "sj-dpi", not "SJ".
ℹ Did you mean "sj"? 
5: Computation failed in `stat_density()`.
Caused by error in `precompute_bw()`:
! `bw` must be one of "nrd0", "nrd", "ucv", "bcv", "sj", "sj-ste", or
  "sj-dpi", not "SJ".
ℹ Did you mean "sj"? 
6: Computation failed in `stat_density()`.
Caused by error in `precompute_bw()`:
! `bw` must be one of "nrd0", "nrd", "ucv", "bcv", "sj", "sj-ste", or
  "sj-dpi", not "SJ".
ℹ Did you mean "sj"? 

Fix

Changed the bandwidth method to lowercase "sj", which is a valid and robust choice for density estimation.

Impact

This fix ensures that density plots are generated correctly without runtime errors, improving the reliability of the plotting templates.

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.

1 participant