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

FREQUENCY not working as expected #43

Open
mjp0 opened this issue Feb 20, 2016 · 0 comments
Open

FREQUENCY not working as expected #43

mjp0 opened this issue Feb 20, 2016 · 0 comments

Comments

@mjp0
Copy link

mjp0 commented Feb 20, 2016

FREQUENCY() is giving me weird results. I feed in 5 numbers as data, i.e. [ 4, 5, 5, 7, 10 ] and my bins are [ [ 4, 6 ], [ 6, 8 ], [ 8, 10 ], [ 10, 12 ], [ 12, 14 ] ] and I get back [ 1, 2, 0, 1, 0, 1, 0, 0, 0, 0, 0 ].

So with 5 items and with 5 buckets I get 11 values back. This is not how FREQUENCY works in Excel.

Any ideas?

edit: quick fix with lodash (note that if value is same as upper bin value, it will be moved to the next bin):

var frequencies = []
    _.each(bins, b => {
        var frequency = 0
        _.each(values, v => {
            if(b[0] <= v  && b[1] > v) {
                frequency++
            }
        })
        frequencies.push({bin: b, frequency: frequency})
    })
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

No branches or pull requests

1 participant