Skip to content

Commit

Permalink
Merge pull request #31 from dmurdoch/labelSubset
Browse files Browse the repository at this point in the history
Don't assume we are on the search list.
  • Loading branch information
dmurdoch authored Aug 22, 2024
2 parents 0c5399f + 0088bbc commit b44f4fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tables
Title: Formula-Driven Table Generation
Version: 0.9.29
Version: 0.9.30
Author: Duncan Murdoch
Description: Computes and displays complex tables of summary statistics.
Output may be in LaTeX, HTML, plain text, or an R
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# tables 0.9.29
# tables 0.9.30

- In a few places `len` was used instead of `length.out` in calls to
`rep()`, leading to warnings. Similarly, `rep` was used instead of
`replace` in `sample()` (issue #28).
- `tabular` assumed it was on the search list, and didn't work when
called as `tables::tabular` (issue #30).

# tables 0.9.28

Expand Down
10 changes: 8 additions & 2 deletions R/tabular.R
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,16 @@ tabular.formula <- function(table, data=NULL, n, suppressLabels=0, ...) {
domain = NA)
if (missing(n) && inherits(data, "data.frame"))
n <- nrow(data)

# We need access to labelSubset() (and perhaps other functions)
# when evaluating a table expression. (Issue #30)

withTableFns <- new.env(parent = if (is.environment(data)) data else environment(table))
withTableFns$labelSubset <- labelSubset
if (is.null(data))
data <- environment(table)
data <- withTableFns
else if (is.list(data))
data <- list2env(data, parent=environment(table))
data <- list2env(data, parent=withTableFns)
else if (!is.environment(data))
stop("'data' must be a dataframe, list or environment")

Expand Down

0 comments on commit b44f4fe

Please sign in to comment.