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

Allow infinite and NA values to be swarmed #20

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

billdenney
Copy link

Fix #19
Related to eclarke/ggbeeswarm#87

This PR does two things (three if you count removing trailing whitespace):

  1. Consolidates the code from swarmx() and swarmy() into swarmboth()
  2. Uses the new, internal xToFinite() function to convert NA, -Inf, and Inf to finite values.

@billdenney billdenney changed the title Allow infinite Allow infinite and NA values to be swarmed May 23, 2023
@billdenney
Copy link
Author

I'm responding to the suggestion to add an argument like

beeswarm(..., allow_infinite = TRUE)

That seems like the best and a straightforward way to maintain backward compatibility. The question I'd like to consider before adding it is: Does the error at the time of transformation give the intended result for the user?

The way that this PR is implemented, it pushes the question of, "Can this be plotted?" to the plotting function. It makes the plot succeed or fail identically to if you had plotted the points without a beeswarm (meaning that beeswarm doesn't make a decision about what can be plotted). For my use cases, I would expect beeswarm to provide the jitter to the points without otherwise making decisions in the process.

My use cases aren't everyone's use cases, so if you disagree, I'll add the argument as you suggest without further push back.

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.

swarmx() and swarmy() fail with infinite inputs
1 participant