Closed KellenBrosnahan closed 3 years ago
I'm not quite sure what you mean by that. Do you mean that I should add an additional test to the test-all.R file?
Yes an additional test under /tests that covers this extra case/regex would be great.
I've never used the testthat package before. Is there a guide for using it? Also, I should be adding the test to the test-surv.R file in the testthat folder, correct?
Here's the test I'm trying to add.
test_that('fortify.survfit regular expression for renaming strata works with multiple stratification variables', {
skip_if_not_installed("survival")
library(survival)
d.survfit <- survival::survfit(Surv(time, status) ~ sex + ph.ecog, data = lung)
fortified <- ggplot2::fortify(d.survfit)
expect_equal(is.data.frame(fortified), TRUE)
expected_names <- c('time', 'n.risk', 'n.event', 'n.censor', 'surv',
'std.err', 'upper', 'lower', 'strata')
expect_equal(names(fortified), expected_names)
expect_equal(length(fortified$strata), 8)
})
When I run test-all.R
with this test included, it fails, and it gives the expected error message under the current version of ggfortify
. Is this because the ggfortify
package hasn't incorporated the fix yet?
@terrytangyuan, is there anything left to do for this?
You are all set. You can try the GitHuh version for now until the new version is on CRAN.
In fortify_surv.R, changed the regular expression on line 49 to be "[^,]=" instead of ".=". This is in response to Issue #214, and the change is meant to allow autoplot to work on survfit objects with multiple stratification variables.
testResults.txt