Fix NOTE about undefined global variable t.1 in pw_info()
#594
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a follow-up to PR #579. It introduced the following NOTE from
R CMD check:This is caused by the following line, which uses the non-standard evaluation feature of {data.table} to update the table by reference:
gsDesign2/R/pw_info.R
Line 189 in 5103d9c
There are various workarounds to fix this:
t.1 <- NULLjust above the line. This is sufficient to satisfyR CMD check, but clutters the code with another line related to an unimportant intermediate variableans[, t.1 := NULL]withans[["t.1"]] <- NULL. I confirmed viadata.table::address()that the latter makes a copy of the data table, but for such a small object, this will have a negligible effect on performanceHowever, I was concerned why
t.1was introduced in the first place. I realized it came from this step, wheretis both calculated and used as a grouping variable. Sincetis inby, there is by definition only a single value, and thus no need to runmin(t).gsDesign2/R/pw_info.R
Lines 176 to 182 in 5103d9c
After I removed
t = min(t), the columnt.1was no longer created becausetbl_eventonly had a single columnt. The NOTE is removed, and the tests all pass. I also ran the code examples below and confirmed the results were identical before and after my change: