-
Notifications
You must be signed in to change notification settings - Fork 11
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
Update type_histogram.R #288
Conversation
do not force common break points across facets. this can be done through the break option. however, passing a vector to break is currently broken as is.null() is not vectorised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this.
I can see that a couple of tests are failing. I'm not sure if it's because of things that I've pointed out in my quick review of the code or something else. Hopefully I'll have time to investigate properly this evening.
R/type_histogram.R
Outdated
datapoints_breaks = hist(datapoints$x, breaks = hbreaks, plot = FALSE) | ||
datapoints = split(datapoints, list(datapoints$by, datapoints$facet)) | ||
datapoints = Filter(function(k) nrow(k) > 0, datapoints) | ||
|
||
datapoints = lapply(datapoints, function(k) { | ||
h = hist(k$x, breaks = datapoints_breaks$breaks, plot = FALSE) | ||
h = hist(k$x, breaks = hbreaks, plot = FALSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can delete the datapoints_breaks
object, since we we should still use it by default in the case of grouped histograms. The thing we want to avoid is different binning widths for each group (unless the user explicitly requests it) which is why we calculate it on the full dataset first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, but atm there is no possibility of different binning for each group/facet since datapoint_breaks
is always passed to breaks
, and there is no possibility of passing a vector of breaks because of ifelse()
. it would be nice if breaks
accepted the same possibilities as hist
(function, vector, number).
i think that different binning by group/facet often makes sense when freq=FALSE
(missing atm).
thanks for looking into this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps introducing an option to allow for free breaks (as in this commit) is an idea...
This is great, thanks @eleuven. I finally had a chance to play around with your suggestion tonight and agree that we need a solution like the one you've proposed here. As it happens, we've just been resolving a similar issue for joint bandwidth selection in grouped density plots (e.g., see here). The solution we landed on there was to introduce a My only hesitation right now is thinking about argument consistency across Let me think on it a bit more and get back to you. |
it looks like my i do not know what the historical background is for however, if i am not mistaken then what is now implemented by just thinking out loud though... |
Yup (specifically
The I appreciate the feedback and discussion, though. Right now, I'm leaning towards a |
Okay, after experimenting, I've decided to stick with a very slightly tweaked version of your Note, however, that this wasn't the main reason free facet scales weren't working. Rather, it was the fact that we were keeping zero count bins. So I've added a new Thanks again for pushing this forward @eleuven! |
do not force common break points across facets. this can be done by passing break points to the
break
option. however, passing a vector tobreak
is currently broken asis.null()
is not vectorised.see here for some background
Fixes #269