Skip to content
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

Fix group_level when printing a character of a number #25

Merged
merged 5 commits into from
Nov 14, 2022
Merged

Conversation

barrettk
Copy link
Collaborator

@barrettk barrettk commented Nov 14, 2022

This PR removes a section that prevented numeric group_levels from being used.

Previously, these values would be overwritten with empty quotes:

  suppressWarnings({
    if(any(is.na(as.numeric(y_tick_names)))){
      y_tick_names[!is.na(as.numeric(y_tick_names))] <- ""
    }
  })

Its unclear why this design choice was chosen. I imagine it was to prevent numeric levels from being passed though, though I dont see why that would be cause for concern.

EDIT: After further inspection, I realized that code I removed was meant to handle no group_level being specified. By removing that code, we now get labels when none is supplied (which is not ideal). To fix this, I modified the section below:

  if (is.null(group_level) || length(group_level) != n) {
    if (!is.null(group_level) && length(group_level) != n) {
      warning("Argument group_level has wrong length and is ignored.")
    }
    group_level <- rep("", n) # used to be 1:n()
  }

Moving forward, both character interpretations of numeric columns, and actual numeric columns can be used:

Character of '10.00'
image

Value of 10
image

closes #24

…reviously, these values would be overwritten with empty quotes. Its unclear why this design choice was chosen
@barrettk
Copy link
Collaborator Author

After further inspection, I realized that code I removed was meant to handle no group_level being specified. By removing that code, we now get labels when none is supplied (which is not ideal). Will adjust the PR description when I find a solution

@kyleam
Copy link
Collaborator

kyleam commented Nov 14, 2022

Character of '10'

The plots show "10.00". Probably just a typo in the PR description, but to make sure: was the character "10" or "10.00"?

df <- df %>% mutate(group_level = as.character(group_level))

plt2 <- plot_forest(df)
vdiffr::expect_doppelganger("Chacter interpretation of numeric group_level", plt2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo: chacter

@barrettk
Copy link
Collaborator Author

The plots show "10.00". Probably just a typo in the PR description, but to make sure: was the character "10" or "10.00"?

Correct, the specified character was "10.00", I just abbreviated it

@kyleam
Copy link
Collaborator

kyleam commented Nov 14, 2022

Correct, the specified character was "10.00", I just abbreviated it

Would you mind expanding it in the description? Abbreviating invites confusion in this case.

Copy link
Collaborator

@kyleam kyleam left a comment

Choose a reason for hiding this comment

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

After further inspection, I realized that code I removed was meant to handle no group_level being specified. By removing that code, we now get labels when none is supplied (which is not ideal). To fix this, I modified the section below:

Thanks for the analysis. I'm largely taking it at face value given I'm not familiar with this codebase, but that makes sense from what I can tell.

Reviewing this I've

From my view, this is good to go once the _snaps/ files are refreshed:
#25 (comment)

@barrettk
Copy link
Collaborator Author

@kyleam I noticed I was getting warnings about size being deprecated in the newest ggplot installation:

Warning (test-nsim-plot.R:23): Multiple simulations: Multiple simulations base test [PMF-PLOT-012]
Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.Please use `linewidth` instead.

Taken from their latest release:

A linewidth aesthetic has been introduced and supersedes the size
aesthetic for scaling the width of lines in line based geoms. size will
remain functioning but deprecated for these geoms and it is recommended to
update all code to reflect the new aesthetic. For geoms that have both point
sizing and linewidth sizing (geom_pointrange() and geom_sf) size now
only refers to sizing of points which can leads to a visual change in old
code (@thomasp85, tidyverse/ggplot2#3672)

It seems this change was introduced in their latest release, and they plan on supporting the old method of size for a while. pmplots might be affected by this change as well, but im wondering when we should incorporate this change, given that we want to support older MPN snapshots, while being sure to make this change before ggplot stops supporting it.

If they were to install this package via install.packages() after size stops being supported, this could lead to issues since it would install the latest version of ggplot

@barrettk barrettk mentioned this pull request Nov 14, 2022
2 tasks
@barrettk barrettk merged commit b0c6887 into main Nov 14, 2022
@kyleam
Copy link
Collaborator

kyleam commented Nov 14, 2022

@kyleam I noticed I was getting warnings about size being deprecated in the newest ggplot installation:

I see you've found gh-26, which mentions this warning, so I'll follow up there (but yes, you're right that we need to consider backward compatibility).

@barrettk barrettk deleted the fix/issue_24 branch November 14, 2022 20:42
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.

group_level not printing when character of a number
2 participants