Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ Collate:
'tt_from_df.R'
'validate_table_struct.R'
'zzz_constants.R'
RoxygenNote: 7.3.3
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method(c,RowsVerticalSection)
S3method(print,CellValue)
S3method(print,RowsVerticalSection)
export("cell_footnotes<-")
Expand Down
37 changes: 37 additions & 0 deletions R/00tabletrees.R
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,43 @@ print.RowsVerticalSection <- function(x, ...) {
invisible(x)
}

#' Combine RowsVerticalSection objects
#' Combine two or more RowsVerticalSection objects (as returned
#' by [in_rows()]) into a single object
#'
#' @param ... RowsVerticalSection objects
#' @returns A single RowsVerticalSection object containing all
#' row sections from the objects passed to `...`
#' @export
c.RowsVerticalSection <- function(...) {
lst <- list(...)
if (!all(sapply(lst, function(x) inherits(x, "RowsVerticalSection")))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use vapply(lst, inherits, logical(1), "RowsVerticalSection") as it is a expected logical

stop("Cannot use c() to combine RowsVerticalSection objects with objects of other classes")
}

out <- NextMethod(generic = "c")
out <- RowsVerticalSection(
out,
names = comb_attr_w_dflt(lst, "row_names"),
labels = comb_attr_w_dflt(lst, "row_labels"),
indent_mods = comb_attr_w_dflt(lst, "indent_mods", 0L),
formats = comb_attr_w_dflt(lst, "row_formats", "xx"),
footnotes = comb_attr_w_dflt(lst, "row_footnotes"),
format_na_strs = comb_attr_w_dflt(lst, "row_na_strs", NA_character_)
)
out
}

comb_attr_w_dflt <- function(lst, attrname, dflt = NULL) {
unlist(
lapply(lst, function(x) {
attr(x, attrname, exact = TRUE) %||% rep(dflt, length(x))
}),
recursive = FALSE,
use.names = FALSE
)
}

#### Empty default objects to avoid repeated calls
## EmptyColInfo <- InstantiatedColumnInfo()
## EmptyElTable <- ElementaryTable()
Expand Down
2 changes: 1 addition & 1 deletion R/make_split_fun.R
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ add_overall_facet <- function(name, label, extra = list()) {
#'
#' @param innervar (`character`)\cr the variable(s) to trim (remove unobserved levels) independently within each facet.
#'
#' @return A function suitable for use in the `pre` (list) argument of `make_split_fun`.
#' @return A function suitable for use in the `post` (list) argument of `make_split_fun`.
Comment thread
gmbecker marked this conversation as resolved.
#'
#' @seealso [make_split_fun()]
#'
Expand Down
30 changes: 28 additions & 2 deletions R/tree_accessors.R
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,10 @@ setGeneric("row_cells", function(obj) standardGeneric("row_cells"))
#' @exportMethod row_cells
setMethod("row_cells", "TableRow", function(obj) obj@leaf_value)

#' @rdname row_accessors
#' @exportMethod row_cells
setMethod("row_cells", "RowsVerticalSection", function(obj) as(obj, "list", strict = TRUE))

#' @rdname row_accessors
setGeneric("row_cells<-", function(obj, value) standardGeneric("row_cells<-"))

Expand All @@ -1017,7 +1021,6 @@ setGeneric("row_values", function(obj) standardGeneric("row_values"))
#' @exportMethod row_values
setMethod("row_values", "TableRow", function(obj) rawvalues(obj@leaf_value))


#' @rdname row_accessors
#' @exportMethod row_values<-
setGeneric("row_values<-", function(obj, value) standardGeneric("row_values<-"))
Expand Down Expand Up @@ -1153,13 +1156,18 @@ setMethod("obj_format", "CellValue", function(obj) attr(obj, "format", exact = T
#' @export
setMethod("obj_format", "Split", function(obj) obj@split_format)

#' @rdname formatters_methods
#' @export
setMethod("obj_format", "RowsVerticalSection", function(obj) attr(obj, "row_formats", exact = TRUE))

#' @rdname formatters_methods
#' @export
setMethod("obj_format<-", "VTableNodeInfo", function(obj, value) {
obj@format <- value
obj
})


#' @rdname formatters_methods
#' @export
setMethod("obj_format<-", "Split", function(obj, value) {
Expand All @@ -1174,13 +1182,27 @@ setMethod("obj_format<-", "CellValue", function(obj, value) {
obj
})

#' @rdname formatters_methods
#' @export
setMethod("obj_format<-", "RowsVerticalSection", function(obj, value) {
attr(obj, "row_formats") <- value
obj
})

#' @rdname int_methods
#' @export
setMethod("obj_na_str<-", "CellValue", function(obj, value) {
attr(obj, "format_na_str") <- value
obj
})

#' @rdname int_methods
#' @export
setMethod("obj_na_str<-", "RowsVerticalSection", function(obj, value) {
attr(obj, "row_na_strs") <- value
obj
})

#' @rdname int_methods
#' @export
setMethod("obj_na_str<-", "VTableNodeInfo", function(obj, value) {
Expand All @@ -1199,6 +1221,10 @@ setMethod("obj_na_str<-", "Split", function(obj, value) {
#' @export
setMethod("obj_na_str", "VTableNodeInfo", function(obj) obj@na_str)

#' @rdname int_methods
#' @export
setMethod("obj_na_str", "RowsVerticalSection", function(obj) attr(obj, "row_na_strs", exact = TRUE))

#' @rdname formatters_methods
#' @export
setMethod("obj_na_str", "Split", function(obj) obj@split_na_str)
Expand Down Expand Up @@ -1678,7 +1704,7 @@ setMethod(
"must have length 1 or the number of rows"
)
}
attr(obj, "indent_mods") <- as.integer(value)
attr(obj, "indent_mods") <- rep(as.integer(value), length.out = length(obj))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the right behavior, but it should be documented in NEWS since it changes the semantics of the setter

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bugfix rather than a semantics change because if you give it a single value something down stream (printing, I think) breaks, but still worth putting in the NEWS file

obj

## obj@indent_mods <- value
Expand Down
8 changes: 8 additions & 0 deletions R/tt_pos_and_access.R
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,14 @@ setMethod(
}
)

#' @rdname int_methods
#' @keywords internal
#' @exportMethod cell_values
setMethod(
"cell_values", "RowsVerticalSection",
function(tt, rowpath, colpath = NULL, omit_labrows = TRUE) rawvalues(tt)
)

#' @rdname int_methods
#' @keywords internal
#' @exportMethod cell_values
Expand Down
2 changes: 2 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ articles:
- guided_intermediate_translating_shells
- guided_intermediate_afun_reqs
- guided_intermediate_split_reqs
- starts_with("guided_advanced")

- title: Clinical Trials
navbar: Clinical Trials
Expand Down Expand Up @@ -323,3 +324,4 @@ reference:
- length,CellValue-method
- names,VTableNodeInfo-method
- insert_rrow
- c.RowsVerticalSection
69 changes: 69 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,66 +1,110 @@
Abinaya
acknowledgements
AE
AEs
afun
afuns
allcols
amongst
ARD
ard
ARDs
args

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

68 new words is a lot. Some look like they could be R object names or code fragments that should be in backticks in the vignettes rather than whitelisted (e.g., afun, afuns, bbbs, splfun). Worth checking if wrapping them in backticks in the Rmd files removes the need for the wordlist entries

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will look into this,s ome of those are real (bbbs stands for Behavioral Building Blocks, which is a term I use heavily in one of the vignettes to refer to the functions we pass to pre and post in make_split_fun, others do look like variable names though

asvec
aut
avar
biomarker
BMEASIFL
Bov
Bov<U+00E9>
Carreras
cbind
CellValue
charset
Cheatsheet
Chohan
clayout
colcount
colinfo
coltree
colvars
combinatorial
compat
constr
coxreg
cran
CRAN's
cre
ctb
customizations
Davide
de
decrementing
degen
desc
Dev
dev
df
dg
differnt
dimensioned
disp
divs
dplyr
elemtable
emph
expr
facetted
facetting
FFFL
fnd
formatter
forseeable
funciton
funder
funs
Garolini
getter
getters
github
Godwin
Heng
Hoffmann
Hofstaedter
href
https
ie
indicies
ing
initializer
insightsengineering
io
kate
Kelkhoff
knitr
labelled
Layouting
layouting
Lewandowski
lyt
mandatorily
Maximo
modelled
Modelling
monospace
Mordig
multivar
multivariable
na
navbar
nesttemplate
NSE
ORCID
orderable
orthogonally
overrided
oversimplifaction
params
Paszty
pathability
pathable
Expand All @@ -69,27 +113,41 @@ Pathing
pathing
Pharma
Phuse
pkgdown
postfix
postprocessing
Pre
pre
Qi
qtable
rcell
reindexed
repped
reqs
responder
Resync
reusability
rheader
rmarkdown
roadmap
RowsVerticalSection
rrow
rrowl
RStudio
rtable
rtablel
rtables
Rua
Saban
Saban<U+00E9>s
Saibah
sep
SKELETOMUSCULAR
sortable
spacelab
spl
Stoilova
struct
STUDYID
subseting
subsplits
Expand All @@ -100,10 +158,15 @@ Subtables
subtables
summarization
tableone
TableTree
Tadeusz
toc
todo
topleft
tostring
traversable
truetype
tt
unaggregated
unicode
uniqify
Expand All @@ -115,9 +178,15 @@ Unstratified
unstratified
useR
ValueWrapper
VignetteEncoding
VignetteEngine
VignetteIndexEntry
visibilities
visibilty
VTableNodeInfo
VTableTree
Waddell
wpcts
xtable
Yogasekaram
Yung
Expand Down
22 changes: 22 additions & 0 deletions man/c.RowsVerticalSection.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading