-
Notifications
You must be signed in to change notification settings - Fork 8
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
Refactor as_rtf()
#450
Conversation
… return a single string
…reused by both as_gt() and as_rtf()
…d of hard-coding `"Null hypothesis"` here?
…ly used inside as_rtf(); is this someone's oversight?
…t will break a test), and I think we should do the same in as_gt()
…le` / `gs_method_subtitle`
…`footnote_non_binding()`
…tially buggy (when `N >= 10`)
…e, so move them into `gs_design_info()`
…()` can match the number of rows in the data
xref: #282 |
@@ -242,115 +250,24 @@ as_gt.gs_design <- function( | |||
display_inf_bound = FALSE, | |||
...) { | |||
|
|||
method <- intersect(class(x), c("ahr", "wlr", "combo", "rd"))[1] | |||
full_alpha <- attr(x, "full_alpha") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LittleBeannie I have a question regarding a difference between as_gt()
and as_rtf()
that I noticed while comparing the two: for as_gt()
, we obtain full_alpha
from the attribute of x
, whereas for as_rtf()
, full_alpha
is its argument and not retrieved from x
's attributes. Is this expected? I'm not sure if you or @elong0527 is the right person to ask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yihui , yes, I can answer the question. The full_alpha
should be retrieved from x
's attributes. I will prepare a PR to get it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to do it, please wait until this PR is merged, or I can just do it in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the confirmation. I know there are many changes occurring in this pull request, so let's wait until this PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yihui, there are lots of work, thank you so much! I only have some very minor comments, regarding the naming of the utility functions.
R/as_gt.R
Outdated
} | ||
|
||
# get the fixed design method | ||
fixed_method <- function(x) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it appropriate to refer to this as the 'fixed_design_method'? From my perspective, the term 'fixed method' implies that the method is fixed, which may have limited clinical significance.
Furthermore, I've observed utility functions for both fixed design (such as fixed_method
, fixed_title
, method_footnote
), as well as group sequential design (such as get_display_columns
, footnote_content
, footnote_non_binding
, footnote_row
, gs_design_info
). I am considering whether it would be beneficial to use distinct prefixes for these two sets of utilities to differentiate their purposes.
Finally, I am wondering if we should save the above 2 sets of utilities into a separate R file, and name it as utility_as_gt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am considering whether it would be beneficial to use distinct prefixes for these two sets of utilities to differentiate their purposes.
I'm using the prefixes fd_
and gsd_
now, and am open to other suggestions. I tend not to use the prefix gs_design_
because I noticed that we have had functions with this prefix but serve a very different purpose. I hope the abbreviations fd
and gsd
make sense. They are only for ourselves and users won't use them, so the naming is perhaps not critically important. Anyway, naming is really hard :)
Finally, I am wondering if we should save the above 2 sets of utilities into a separate R file, and name it as
utility_as_gt
.
I don't have an opinion on that. I can certainly put these functions in as_utils.R
if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the fd
and gsd
, which are sufficiently clear for developers. I am also good for the current folder/file structure. I will get it merged. Thanks for all the work!
R/as_gt.R
Outdated
if (is.null(title)) title <- sprintf("Fixed Design %s Method", switch( | ||
design_mtd, | ||
# get the default title | ||
fixed_title <- function(method) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Echo with my previous comment, can we call this function as fixed_design_title
?
R/as_gt.R
Outdated
if (is.null(footnote)) footnote <- switch( | ||
design_mtd, | ||
# get the default footnote | ||
method_footnote <- function(x, method) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering why the prefix of fixed_
is missing... Is the method_footnote
appliable for both fixed design and group sequential design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was simply being lazy. It was only for fixed design.
@@ -242,115 +250,24 @@ as_gt.gs_design <- function( | |||
display_inf_bound = FALSE, | |||
...) { | |||
|
|||
method <- intersect(class(x), c("ahr", "wlr", "combo", "rd"))[1] | |||
full_alpha <- attr(x, "full_alpha") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yihui , yes, I can answer the question. The full_alpha
should be retrieved from x
's attributes. I will prepare a PR to get it there.
R/as_gt.R
Outdated
} | ||
|
||
# a list of information for `as_[gt|rtf].gs_design()` methods | ||
gs_design_info <- function( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am hesitant to use gs_design_info
as the name, as info
in gsDesign2 carries a specific meaning – statistical information (1/variance). Can we consider an alternative name for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming of this function is the hardest. I spent nearly half an hour on it but couldn't think of a better name. I ended up using gsd_parts()
. Please feel free to suggestion a different one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, naming is always the hardest part. As long as we could get rid of the info
as keywords, we should be good. The new name gsd_parts
looks good to me.
Massive refactoring of
as_rtf()
to share code withas_gt()
.