-
Notifications
You must be signed in to change notification settings - Fork 164
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
addresses #578 - use dplyr::select insstead of select_ #579
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c4a3de1
addresses #578 - use dplyr::select insstead of select_
tbaer-c7ks7s 359c0c0
#578 update tests and replace a few select and as.tibbles
tbaer-c7ks7s be678e6
#509 replace select_ with select in surv_median
tbaer-c7ks7s b35b1cb
#577 replace deprecated function with superceded function
tbaer-c7ks7s 68c9969
doc updated
kassambara 761a2e9
fix for dplyr:select()
kassambara 7c4ad15
fix lung data not found in unit test
kassambara 281aae3
Merge branch 'master' into dplyr_1_warnings
kassambara eb7f42d
ggplot2 minimum version set to 3.4.0
kassambara c7ff628
gather replaced by pivot_longer()
kassambara b7c4fae
deprecated aes_string() replaced by aes()
kassambara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ surv_median <- function(fit, combine = FALSE){ | |
.table$strata <- rownames(.table) | ||
|
||
.table <- .table %>% | ||
dplyr::select_(.dots = c("strata", "median", "`0.95LCL`", "`0.95UCL`")) | ||
dplyr::select(strata, median, `0.95LCL`, `0.95UCL`) | ||
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. As above (to avoid R check warnings), the code should be: dplyr::select(dplyr::all_of(c("strata", "median", "0.95LCL", "0.95UCL"))) |
||
colnames(.table) <- c("strata", "median", "lower", "upper") | ||
rownames(.table) <- NULL | ||
.table | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
library(survival) | ||
data('cancer') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
test_that('ggcoxdiagnostics creates plot with all the observations', { | ||
cph <- coxph(Surv(futime, fustat) ~ rx + age, data=ovarian) | ||
p <- ggcoxdiagnostics(cph, type="deviance") | ||
.build <- ggplot_build(p) | ||
expect_equal(nrow(.build$data[[1]]), nrow(ovarian)) | ||
}) | ||
|
||
test_that('ggcoxdiagnostics with second type two rows for each observed event*term', { | ||
cph <- coxph(Surv(futime, fustat) ~ rx + age, data=ovarian) | ||
qty_terms <- length(attr(terms(cph$formula), "term.labels")) | ||
qty_events <- sum(ovarian$fustat==1) | ||
p <- ggcoxdiagnostics(cph, type="schoenfeld") | ||
.build <- ggplot_build(p) | ||
expect_equal(nrow(.build$data[[1]]), qty_terms*qty_events) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
start_time <- 250 | ||
fit1 <- survfit(Surv(time, status) ~ sex, data = lung) | ||
fit2 <- survfit(Surv(time, status) ~ sex, data = lung, start.time = start_time) | ||
|
||
test_that("survplot_combine plots successfully into 4 lines; second 2 fits have only (0,1) before start_time", { | ||
p <- ggsurvplot_combine(list( | ||
original=fit1, conditional=fit2 | ||
), data = lung) | ||
.build <- ggplot_build(p$plot) | ||
.build_data <- .build$data[[1]] | ||
expect_equal(length(unique(.build_data[['group']])), 4) | ||
expect_lt(nrow(.build_data[(.build_data[['group']] >= 3) & | ||
(.build_data[['x']] < start_time), ]), 3) | ||
}) | ||
|
||
test_that("survplot_combine includes dataframes when keep.data==TRUE", { | ||
p <- ggsurvplot_combine(list( | ||
original=fit1, conditional=fit2 | ||
), data = lung, keep.data = TRUE) | ||
expect_equal(length(names(p)), 3) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
test_that("ggsurvplot_facet creates the correct quanitty of subplots", { | ||
fit <- survfit(Surv(time, status) ~ sex, data=kidney) | ||
p <- ggsurvplot_facet(fit, kidney, facet.by='disease') | ||
.build <- ggplot_build(p) | ||
expect_equal(nrow(.build$data[[2]]), | ||
length(unique(kidney[['disease']]))) | ||
|
||
fit <- survfit(Surv(time, status) ~ disease, data=kidney) | ||
p <- ggsurvplot_facet(fit, kidney, facet.by='sex') | ||
.build <- ggplot_build(p) | ||
expect_equal(nrow(.build$data[[2]]), | ||
length(unique(kidney[['sex']]))) | ||
}) | ||
|
||
test_that("ggsurvplot_facet calculates pvalue for each facet", { | ||
fit <- survfit(Surv(time, status) ~ sex, data=kidney) | ||
p <- ggsurvplot_facet(fit, kidney, facet.by='disease', pval = TRUE) | ||
.build <- ggplot_build(p) | ||
expect_equal(nrow(.build$plot$layer[[4]][['data']]), | ||
length(unique(kidney[['disease']]))) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
test_that("surv_median calculates medians", { | ||
df_medians <- surv_median(survfit(Surv(time, status) ~ sex, | ||
data=lung)) | ||
expect_equal(df_medians[['median']], c(270,426)) | ||
expect_lt(df_medians[['lower']][2], 426) | ||
}) |
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.
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.
To avoid R cmd check warning, quotes are needed around variables. The code should look like this: