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

weighted* for logical x raises error #162

Closed
mayer79 opened this issue Dec 18, 2019 · 3 comments
Closed

weighted* for logical x raises error #162

mayer79 opened this issue Dec 18, 2019 · 3 comments

Comments

@mayer79
Copy link

mayer79 commented Dec 18, 2019

I was recently stumbling over the weighted* functions with logical input:

weightedMean(1:10 > 5) # Error
weightedMedian(1:10 > 5) # Error
weightedVar(1:10 > 5) # Works

Would it be possible to catch this case in an efficient way?

@HenrikBengtsson
Copy link
Owner

Thanks for reporting. For the record/clarification:

> weightedMean(1:10 > 5)
Error in weightedMean(1:10 > 5) : Argument 'x' cannot be logical.

> weightedMedian(1:10 > 5)
Error in weightedMedian(1:10 > 5) : Argument 'x' cannot be logical.

> weightedVar(1:10 > 5)
[1] 0.2777778

Q. Is this a request for weightedVar() to also give an error, or is it a request for supporting weighted mean/median on logical input?

@mayer79
Copy link
Author

mayer79 commented Dec 18, 2019

Hello Henrik, thanks for responding. I'd prefer a version for logical input, like stats::weightedMean or mean.

@HenrikBengtsson
Copy link
Owner

FYI, support for logical input to weightedMean(), weightedMedian(), and their counterpart row- and column-based functions has been added to the 'develop' branch (= next release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants