-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
run* functions optionally return all NA if nrow(x) < n #68
Comments
I would wholeheartedly support this approach. I think it would improve the consistency of many of these functions. take a simple example:
here, I think we all agree that the ramp-up until row >=n properly returns NA. So any code using these results already has to handle the leading NA in the output. returning properly structured and named output that had all NA values would greatly simplify downstream processing. in fact, I generally consider the case where nrow(x) < n to be a degenerate form of ramp-up. Also, selfishly, it would allow me to get rid of my ever-growing (and very poorly implemented) library of wrappers to handle this, so I'd be willing to help on the project if it gets greenlighted:
|
Thanks for the comment! It's good to know that you created wrapper functions to deal with this. That means you encounter it enough for those function to be useful for you, which means it probably affects others similarly. I also think it's worth considering throwing a warning when the function will return all NA, since it's likely possible the user didn't expect that. Maybe with a global option to suppress the warning? Thoughts? |
Agree on a warning, and that a global option is probably better than per function parameters as I suspect most people would want this functionality to be consistent (i.e. always warn, or never warn) Also, I think it probably needs a transitional global option to support existing functionality for backward comparability as some people may have existing try/catch blocks that depend on the error |
rethinking this a bit, another option is to add a
|
Hello Joshua, I hope you are doing well. It's been a (very) long time since parDeoptim etc. (via KB). As follows :: SEXP runprod(SEXP x, SEXP n) {
} |
Michael Ohlrogge commented on my answer to "Moving variance in R" that it could be useful for the run* functions to return a vector of
NA
the same length as the input whenn
is greater than the number of non-NA observations in the input object.Need to investigate what
zoo::rollapply()
and friends do in this case.The text was updated successfully, but these errors were encountered: