Skip to content

Commit

Permalink
Another fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmurdoch committed Aug 29, 2024
1 parent 8774121 commit 8104933
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions R/tabular.R
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,19 @@ tabular.formula <- function(table, data=NULL, n, suppressLabels=0, ...) {
if (missing(n) && inherits(data, "data.frame"))
n <- nrow(data)

if (is.null(data))
data <- environment(table)
# We need access to labelSubset() (and perhaps other functions in future)
# when evaluating a table expression (issue #30), but we don't want
# to mask the user's copy.

parent <- if (is.environment(data)) data else environment(table)
if (!exists("labelSubset", envir = parent)) {
withTableFns <- new.env(parent = parent)
withTableFns$labelSubset <- labelSubset
} else
withTableFns <- parent

if (is.null(data) || is.environment(data))
data <- withTableFns
else if (is.list(data))
data <- list2env(data, parent = environment(table))
else if (!is.environment(data))
Expand Down

0 comments on commit 8104933

Please sign in to comment.