-
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
Tweaking as_gt() #449
Tweaking as_gt() #449
Changes from 21 commits
c65e170
aaccf68
88d6650
768edcc
7e2e2e2
caa87e1
e08779c
cb4f64b
d39e657
fd923a7
9bf78b7
ae7a8ce
747cdf3
e6f357c
fbc081b
812c3f5
7863194
8e4bad5
17fce05
2267998
24113fd
7168d2d
90352a0
2494e57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,14 +84,14 @@ ahr_blinded <- function( | |
hr = c(1, .6), | ||
ratio = 1) { | ||
# Input checking | ||
if (!is.vector(hr, mode = "numeric") || min(hr) <= 0) { | ||
stop("ahr_blinded: hr must be a vector of positive numbers.") | ||
if (!is.numeric(hr) || min(hr) <= 0) { | ||
stop("'hr' must be a vector of positive numbers.") | ||
} | ||
if (!is.vector(intervals, mode = "numeric") || min(intervals) <= 0) { | ||
stop("ahr_blinded: intervals must be a vector of positive numbers.") | ||
if (!is.numeric(intervals) || min(intervals) <= 0) { | ||
stop("'intervals' must be a vector of positive numbers.") | ||
} | ||
if (length(intervals) != length(hr)) { | ||
stop("ahr_blinded: the piecewise model specified hr and intervals are not aligned.") | ||
stop("the piecewise model specified 'hr' and 'intervals' differ in length.") | ||
} | ||
|
||
# Set final element of "intervals" to Inf | ||
|
@@ -111,11 +111,10 @@ ahr_blinded <- function( | |
# Compute adjustment for information | ||
q_e <- ratio / (1 + ratio) | ||
|
||
ans <- tibble( | ||
tibble( | ||
event = sum(event), | ||
ahr = exp(-theta), | ||
theta = theta, | ||
info0 = sum(event) * (1 - q_e) * q_e | ||
) | ||
return(ans) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I like the explicit return even though it is optional. And checking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have a strong opinion here and can definitely use an explicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LittleBeannie Do you have a preference here? As I said, I'm totally fine with reverting to the original style There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for verifying, @yihui ! I personally prefer the explicit return, as it provides a clearer message for non-advanced R programmers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. I've restored |
||
} |
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, I have a question regarding the error message output. Typically, our practice in gsDesign2 is to print the function name at the beginning of the error message. This consideration arises from the possibility that the
ahr_blinded
function could potentially be invoked within another function. So... I am wondering if we should keep theahr_blinded
here?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.
Good question. I deleted the function name in the error message because I thought it would be redundant.
This relates to a comment I made after #448 (comment) That is, the function name will be missing if you
do.call
the function.I think this case is relatively rare (so far we have used
do.call()
mostly withrbind
/cbind
in this package). If it does happen,traceback()
can be helpful to know the chain of function calls.That said, again I don't have a strong opinion here. In general, my principle is that I'll follow the preference of the project maintainer (i.e. you in this case).
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.
Thank you for the clear explanation; I understand your intention. I am open to this. If we choose to remove the function name at the beginning of the error message, we should review the entire gsDesign2 package, as the previous practice of gsDesign2 is to include the function name right at the start (maybe a new issue and 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.
Okay, as I'm going through the whole codebase, I'll do this along the way.
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, @yihui! This is not urgent and thanks again for reviewing the codes!
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 searched the repository for how
ahr_blinded()
is used. From the package code, examples, and tests,ahr_blinded()
is always called directly. In other words, the function itself is never passed as an argument to another function. Thus the fact that an error comes fromahr_blinded()
should be clear from the default error message, as @yihui noted above.To demonstrate, I added
stop("there was an error")
toahr_blinded()
and generated the error message below: