Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jun 23, 2024
1 parent 51c8b5f commit 17f8736
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/data_tabulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ data_tabulate.default <- function(x,
# frequency table
if (is.null(weights)) {
if (remove_na) {
# we have a `.default` and a `.data.frame` method for `data_tabulate()`.
# since this is the default, `x` can be an object which cannot be used
# with `table()`, that's why we add `tryCatch()` here. Below we give an
# informative error message for non-supported objects.
freq_table <- tryCatch(table(x), error = function(e) NULL)
} else {
freq_table <- tryCatch(table(addNA(x)), error = function(e) NULL)
Expand Down
4 changes: 4 additions & 0 deletions R/data_xtabulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
}
# frequency table
if (is.null(weights)) {
# we have a `.default` and a `.data.frame` method for `data_tabulate()`.
# since this is the default, `x` can be an object which cannot be used
# with `table()`, that's why we add `tryCatch()` here. Below we give an
# informative error message for non-supported objects.
if (remove_na) {
x_table <- tryCatch(table(x, by), error = function(e) NULL)
} else {
Expand Down

0 comments on commit 17f8736

Please sign in to comment.