Skip to content

Commit

Permalink
Merge pull request #24 from dmurdoch/emptyfactor
Browse files Browse the repository at this point in the history
Handle empty factor level.

Fixes #19
  • Loading branch information
dmurdoch authored Jun 4, 2024
2 parents d59c0b2 + 9e48935 commit 997ff12
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- uses: r-lib/actions/setup-tinytex@v2
- run: tlmgr --version
- run: tlmgr install colortbl grfext ae
- run: tlmgr install colortbl grfext ae tabu
- run: tlmgr list --only-installed
- uses: r-lib/actions/setup-r@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions 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.25
Version: 0.9.26
Author: Duncan Murdoch
Description: Computes and displays complex tables of summary statistics.
Output may be in LaTeX, HTML, plain text, or an R
Expand All @@ -11,7 +11,7 @@ Depends: R (>= 2.12.0)
Imports: stats, utils, knitr, htmltools
Suggests: magrittr, kableExtra (>= 0.9.0), Hmisc, bookdown, rmarkdown,
pkgdown, formatters, tinytable (>= 0.0.5)
VignetteBuilder: knitr
VignetteBuilder: rmarkdown
URL: https://dmurdoch.github.io/tables/
BugReports: https://github.com/dmurdoch/tables/issues
SystemRequirements: pandoc (>= 1.12.3) for vignettes
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# tables 0.9.26

- A factor level of `""` caused an error when displayed. It will
now be changed to `" "` for display (issue #19).
- The `VignetteBuilder` field in `DESCRIPTION` has been changed to
`rmarkdown` so that Pandoc can be found even when it is not on the `PATH`.

# tables 0.9.25

- `PlusMinus()` and `Paste()` didn't handle formatting properly
Expand Down
2 changes: 1 addition & 1 deletion R/All.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ All <- function(df,
else
next

f1 <- call("*", call("Heading", as.name(names[i])),
f1 <- call("*", call("Heading", makeName(names[i])),
value)
if (is.null(f))
f <- f1
Expand Down
2 changes: 1 addition & 1 deletion R/RowFactor.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ RowFactor <- function(x, name = deparse(expr), levelnames=levels(x),
test <- call("labelSubset",
subset = call("==", call("as.integer", call("as.factor", expr)), i),
label = deparse(expr))
term <- call("*", call("Heading", as.name(catname)),
term <- call("*", call("Heading", makeName(catname)),
test)
if (i == 1)
f <- term
Expand Down
6 changes: 6 additions & 0 deletions R/makeName.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
makeName <- function(s) {
stopifnot(length(s) == 1)
if (!nchar(s))
s <- " "
as.name(s)
}
4 changes: 2 additions & 2 deletions R/tabular.R
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,10 @@ expandFactors <- function(e, env) {
rhs <- expandFactors(e[[3]], env)
if (is.call(rhs) && deparse(rhs[[1]]) == "*"
&& is.call(rhs[[2]]) && deparse(rhs[[c(2,1)]]) == "Heading") {
rhs[[c(2,2)]] <- as.name(deparse(e[[2]]))
rhs[[c(2,2)]] <- makeName(deparse(e[[2]]))
rhs
} else
call("*", call("Heading", as.name(deparse(e[[2]]))), rhs)
call("*", call("Heading", makeName(deparse(e[[2]]))), rhs)
} else if (op == ".Format" || op == "Heading" ||
op == "Justify" || op == "Percent" ||
op == "Arguments" || op == "DropEmpty")
Expand Down

0 comments on commit 997ff12

Please sign in to comment.