-
Notifications
You must be signed in to change notification settings - Fork 0
95_waterfall_plot_bugs #100
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
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. Nickel le nouveau fichier. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| test_that("waterfall_plot", { | ||
| local_options(grstat_lifecycle_verbosity="quiet") | ||
|
|
||
| db = grstat_example(N=50) | ||
| data_best_resp = calc_best_response(db$recist) | ||
|
|
||
| #simple example | ||
| p1 = waterfall_plot(data_best_resp) | ||
| vdiffr::expect_doppelganger("waterfall-plot-default", p1) | ||
|
|
||
| #facet by arm | ||
| p2 = data_best_resp %>% | ||
| left_join(db$enrolres, by="subjid") %>% | ||
| waterfall_plot(arm="ARM") | ||
| vdiffr::expect_doppelganger("waterfall-plot-arms", p2) | ||
|
|
||
|
|
||
| #add symbols | ||
| #use the NA level to not show the case | ||
| set.seed(0) | ||
| data_symbols = db$recist %>% | ||
| summarise(new_lesion=ifelse(any(rcnew=="Yes", na.rm=TRUE), "New lesion", NA), | ||
| random=cut(runif(1), breaks=c(0,0.05,0.1,1), labels=c("A", "B", NA)), | ||
| .by=subjid) | ||
|
|
||
| p3 = data_best_resp %>% | ||
| left_join(data_symbols, by="subjid") %>% | ||
| waterfall_plot(shape="new_lesion") | ||
| vdiffr::expect_doppelganger("waterfall-plot-shape1", p3) | ||
|
|
||
| p4 = data_best_resp %>% | ||
| left_join(data_symbols, by="subjid") %>% | ||
| waterfall_plot(shape="random") + | ||
| labs(shape="Event") | ||
| vdiffr::expect_doppelganger("waterfall-plot-shape2", p4) | ||
|
|
||
| set.seed(123) | ||
| data_na = | ||
| data_best_resp %>% | ||
| dplyr::mutate( | ||
| target_sum_diff_first = runif(n(), -0.6, 0.3), | ||
| target_sum_diff_first = replace(target_sum_diff_first, c(1, 3, 10), NA) | ||
|
Comment on lines
+41
to
+42
Member
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. Alternativement, tu peux :
target_sum_diff_first = if_else(runif(n())<0.2, NA, target_sum_diff_first) # 20% de NA
target_sum_diff_first = if_else(row_number()>40, NA, target_sum_diff_first), # 10 dernières
best_response = if_else(row_number()<10, NA, best_response), # 10 premières |
||
| ) | ||
|
|
||
| expect_warning( | ||
| p <- waterfall_plot(data_na, warnings = TRUE), | ||
| regexp = "ignore" | ||
| ) | ||
|
Comment on lines
+45
to
+48
Member
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. Regarde mes appels à |
||
|
|
||
|
|
||
| }) | ||
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.
{}après un pipe, c'est considéré comme peu lisible : on est censé être "à l'intérieur" d'une table mais on a des if/else au liste de ifelse(), ça oblige à utiliser.partout, etc.fct_reorder2(.na_rm=FALSE)