forked from ddsjoberg/gtsummary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modify_column_hide.R
59 lines (55 loc) · 1.45 KB
/
modify_column_hide.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#' Modify Hidden Columns
#'
#' \lifecycle{maturing}
#' Use these functions to hide or unhide columns in a gtsummary table.
#'
#' @inheritParams modify_table_styling
#'
#' @name modify_column_hide
#' @family Advanced modifiers
#' @examples
#' \donttest{
#' # Example 1 ----------------------------------
#' # hide 95% CI, and replace with standard error
#' modify_column_hide_ex1 <-
#' lm(age ~ marker + grade, trial) %>%
#' tbl_regression() %>%
#' modify_column_hide(columns = ci) %>%
#' modify_column_unhide(columns = std.error)
#' }
#' @section Example Output:
#' \if{html}{Example 1}
#'
#' \if{html}{\out{
#' `r man_create_image_tag(file = "modify_column_hide_ex1.png", width = "45")`
#' }}
NULL
#' @rdname modify_column_hide
#' @seealso Review [list, formula, and selector syntax][syntax] used throughout gtsummary
#' @export
modify_column_hide <- function(x, columns) {
.assert_class(x, "gtsummary")
updated_call_list <- c(x$call_list, list(modify_column_hide = match.call()))
x <-
modify_table_styling(
x = x,
columns = {{ columns }},
hide = TRUE
)
x$call_list <- updated_call_list
x
}
#' @rdname modify_column_hide
#' @export
modify_column_unhide <- function(x, columns) {
.assert_class(x, "gtsummary")
updated_call_list <- c(x$call_list, list(modify_column_unhide = match.call()))
x <-
modify_table_styling(
x = x,
columns = {{ columns }},
hide = FALSE
)
x$call_list <- updated_call_list
x
}