Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor as_rtf() #450

Merged
merged 44 commits into from
Aug 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d01df19
tweak error message
yihui Aug 12, 2024
5485aec
remove the redundant paste0() call: paste(collapse = ' | ') will jus…
yihui Aug 12, 2024
1a0da68
introduce the %||% operator
yihui Aug 12, 2024
fc0d3e1
merge the two assignments
yihui Aug 12, 2024
52a5165
"weld" the few short pipes into one expression
yihui Aug 12, 2024
cb14c1b
factor out the code to generate the default title and footnote to be …
yihui Aug 12, 2024
4c92673
an alternative way to find the method
yihui Aug 12, 2024
5e493b5
perhaps we should use `colname_spannersub[2]` as in `as_gt()`, instea…
yihui Aug 12, 2024
6dd6164
copy from as_gt()
yihui Aug 12, 2024
becd0e0
copying from as_gt(): the argument `display_inf_bound` was not actual…
yihui Aug 12, 2024
642e498
rename design_method() to fixed_design_method()
yihui Aug 12, 2024
e271130
factor out gs_design_method()
yihui Aug 12, 2024
c2c640e
copy from as_gt() (will see how to refactor the code later)
yihui Aug 12, 2024
26c3d2b
copy from as_rtf.fixed_design()
yihui Aug 12, 2024
6b34090
use %||%
yihui Aug 12, 2024
98c0bca
2:length is equivalent to -1 (well, assuming length >= 2)
yihui Aug 12, 2024
680fc01
simplify these border variables a little bit
yihui Aug 12, 2024
ee5387a
intToUtf8() sounds like an overkill; we can simply index the `letters…
yihui Aug 12, 2024
709bc05
factor out the row/column indices to make [] thinner
yihui Aug 12, 2024
a16e25c
I don't think `footnotes` can be NULL
yihui Aug 12, 2024
f705696
this element should be hard-coded as `"Null hypothesis"` (otherwise i…
yihui Aug 13, 2024
bb3397a
factor out more strings into footnote_content()
yihui Aug 13, 2024
b0fb333
reuse footnote_content() and eliminate line breaks (which don't matte…
yihui Aug 13, 2024
73370df
amend c2c640e5306ed5e9c4002f14ac6c68ef2ac91d11: factor out the defaul…
yihui Aug 13, 2024
9c7308a
it may be more readable without using a closure from local()
yihui Aug 13, 2024
ebfb904
rename `method_title` to `fixed_method_title`, and add `gs_method_tit…
yihui Aug 13, 2024
7899504
factor out the code to get/transform `display_columns`
yihui Aug 13, 2024
0da4be1
shorten function names
yihui Aug 13, 2024
b5ba260
make this function a one-liner based on the fact that an assignment w…
yihui Aug 13, 2024
584f485
cosmetic changes
yihui Aug 13, 2024
4e321d2
factor out the code to add footnotes and write RTF
yihui Aug 13, 2024
998ef29
delete an extra space (nobody has discovered this before? unbelievable)
yihui Aug 13, 2024
bd00877
factor out the code to check the `col_rel_width`
yihui Aug 13, 2024
247b00e
factor out more common code from as_gt.gs_design() and as_rtf.gs_desi…
yihui Aug 13, 2024
476a635
collect footnotes using c() and concatenate all with paste(..., colla…
yihui Aug 13, 2024
ac4a83d
move the logic `inherits('non_binding') & x_alpha < full_alpha` into …
yihui Aug 13, 2024
49b23a9
factor out `substr(Analysis, 1, 11) == 'Analysis: N'`, which is poten…
yihui Aug 13, 2024
9522d70
the functions `gs_[sub]title` are simple enough and not used elsewher…
yihui Aug 13, 2024
a598ec6
use the processed `x` from `info` so that the length of `footnote_row…
yihui Aug 13, 2024
3654e0f
bump version
yihui Aug 13, 2024
5397198
more comments
yihui Aug 14, 2024
954a226
misplaced ) [ci skip]
yihui Aug 14, 2024
d353d81
Merge branch 'main' into as_rtf_tweaks
yihui Aug 16, 2024
12cec74
renaming using the prefixes `fd_` and `gsd_`
yihui Aug 16, 2024
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
2 changes: 1 addition & 1 deletion R/as_rtf.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ as_rtf.gs_design <- function(
orientation <- match.arg(orientation)

method <- intersect(class(x), c("ahr", "wlr", "combo", "rd"))[1]
x_alpha <- max((x %>% dplyr::filter(Bound == display_bound[1]))[["Null hypothesis"]])
x_alpha <- max(filter(x, Bound == display_bound[1])[[colname_spannersub[2]]])
yihui marked this conversation as resolved.
Show resolved Hide resolved
x_non_binding <- "non_binding" %in% class(x)
x_k <- lapply(x$Analysis, function(x) {
return(as.numeric(substring(x, 11, 11)))
Expand Down