8000 Add option for "impartial binning" for histograms · Issue #11 · hadley/ggstat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Add option for "impartial binning" for histograms #11
Open
@rpruim

Description

@rpruim

From @rpruim on July 26, 2016 12:40

Traditionally (i.e., in hist()) one must choose between left-leaning and right-leaning binning with right = FALSE or right = TRUE. A more balanced option would be to allow right = 0.5. Under this option, data values exactly on a bin border would count has 0.5 in the bin to the left and 0.5 in the bin to the right.

Naive implementation is easy:

newcounts <- 
  right       * hist(..., right =  TRUE)$counts + 
  (1 - right) * hist(..., right = FALSE)$counts

This would work for other values of right a well, although it is less clear that other values are useful. Setting right = TRUE or right = FALSE still works as before (although less efficiently).

Copied from original issue: tidyverse/ggplot2#1680

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0