Skip to content

Commit

Permalink
Narrow fix to 173 with devel vbump.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbecker committed Mar 12, 2021
1 parent ceab54d commit 39c655e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rtables
Title: Reporting Tables
Date: 2020-12-21
Version: 0.3.6.0001
Version: 0.3.6.0002
Authors@R: c(
person("Gabriel", "Becker", email = "gabembecker@gmail.com", role = c("aut", "cre")),
person("Adrian", "Waddell", email = "adrian.waddell@roche.com", role = "aut"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## rtables 0.3.6.0002
* Added `vars_in_layout` to list (explicitly named only) variables used in a layout
* Fix column label ordering bug when value label variable is a factor (#173)

## rtables 0.3.6

Documentation revisions as requested by CRAN. No change to package code.
Expand Down
15 changes: 9 additions & 6 deletions R/split_funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -435,25 +435,28 @@ setMethod(".applysplit_partlabels", "VarLevelSplit",
vlabelname <- spl_labelvar(spl)
varvec = df[[varname]]
if(is.null(vals)) {

vals = if(is.factor(varvec))
levels(varvec)
else
unique(varvec)
}
if(is.null(labels)) {
if(varname == vlabelname)
if(varname == vlabelname) {
labels = vals
else if (is.factor(df[[vlabelname]]))
labels = levels(df[varvec %in% vals, ][[vlabelname]])
else {
## } else if (is.factor(df[[vlabelname]])) {
## labels = levels(df[varvec %in% vals, ][[vlabelname]])
} else {
labfact <- is.factor(df[[vlabelname]])
lablevs <- if(labfact) levels(df[[vlabelname]]) else NULL
labels = sapply(vals, function(v) {
vlabel = unique(df[varvec == v,
vlabelname, drop = TRUE])
## TODO remove this once 1-to-1 value-label map is enforced elsewhere.
stopifnot(length(vlabel) < 2)
if(length(vlabel) == 0)
vlabel = ""
vlabel = ""
else if(labfact)
vlabel <- lablevs[vlabel]
vlabel
})
}
Expand Down

0 comments on commit 39c655e

Please sign in to comment.