-
Notifications
You must be signed in to change notification settings - Fork 12
Add a generic for table #209
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
base: main
Are you sure you want to change the base?
Conversation
|
As well as in #189 the |
This reverts commit e9ad587.
|
As soon as PR #227 is merged the checks with calling |
| table = function(..., exclude=if (useNA == "no") c(NA, NaN), useNA=c("no", "ifany", "always"), dnn=list.names(...), deparse.level=1L) UseMethod("table") | ||
| #' @exportS3Method table default | ||
| table.default = function(..., exclude=if (useNA == "no") c(NA, NaN), useNA=c("no", "ifany", "always"), dnn=list.names(...), deparse.level=1L) { | ||
| if (...length() && any(unlist(lapply(list(...), is.integer64)))) { |
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.
| if (...length() && any(unlist(lapply(list(...), is.integer64)))) { | |
| if (...length() && vapply(list(...), is.integer64, logical(1L))) { |
| ) | ||
| } | ||
| } | ||
| choose_sys_call = function(function_names, name_to_display=NULL) { |
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.
let's move it to zzz.R to make the diff clearer, if any
| #' @exportS3Method table default | ||
| table.default = function(..., exclude=if (useNA == "no") c(NA, NaN), useNA=c("no", "ifany", "always"), dnn=list.names(...), deparse.level=1L) { | ||
| if (...length() && any(unlist(lapply(list(...), is.integer64)))) { | ||
| withCallingHandlers({ |
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.
this can be replaced too, right?
| stop(errorCondition(gettext("all arguments must have the same length", domain="R-base"), call=choose_sys_call(c("table", "table.integer64")))) | ||
| if (!is.integer64(a)) { | ||
| warning("coercing argument ", i, " to integer64") | ||
| warning(warningCondition(paste0("coercing argument ", i, " to integer64"), call=choose_sys_call(c("table", "table.integer64")))) |
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.
Is it required to do this? e.g., it breaks table(x, y) for y a string.
We can mark this as a follow-up, checking your thoughts here first.
A generic for table is added. The
table.defaultchecks the arguments in..., whether it containsinteger64. If so,table.integer64is called. Otherwisebase::tableis called.In
table.defaultthe warnings und errors of underlying methods are captured and recreated to display nice condition messages.table.integer64is not exported anymore.sortcache,sortordercacheandordercachehave a new argumentna.lastin order to havetable.integer64consistent tobase::tablewhen it comes toNAvalues.table.integer64has two new argumentsexcludeanduseNAto be consistent withbase::table.Where possible the translation of base-R is used for condition messages.
I added a helper function
choose_sys_call()to determine the desired sys.call to be used in the condition messages.Closes #59