From 17f8736c0c3354c20cf98adf60d9622e9d1b229b Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 23 Jun 2024 12:42:50 +0200 Subject: [PATCH] add comment --- R/data_tabulate.R | 4 ++++ R/data_xtabulate.R | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/R/data_tabulate.R b/R/data_tabulate.R index 952f921d9..e94fc5d55 100644 --- a/R/data_tabulate.R +++ b/R/data_tabulate.R @@ -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) diff --git a/R/data_xtabulate.R b/R/data_xtabulate.R index 7943cbab9..08be1eeca 100644 --- a/R/data_xtabulate.R +++ b/R/data_xtabulate.R @@ -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 {