Skip to content

95_waterfall_plot_bugs#100

Draft
AnneLO83 wants to merge 1 commit intomainfrom
95-waterfall_plot-bugs
Draft

95_waterfall_plot_bugs#100
AnneLO83 wants to merge 1 commit intomainfrom
95-waterfall_plot-bugs

Conversation

@AnneLO83
Copy link
Contributor

@AnneLO83 AnneLO83 commented Dec 4, 2025

gestion des NA dans target_sum_diff_first + création de test-waterfall-plot.R

gestion des NA dans target_sum_diff_first + création de test-waterfall-plot.R
@AnneLO83 AnneLO83 linked an issue Dec 4, 2025 that may be closed by this pull request
2 tasks
Copy link
Member

@DanChaltiel DanChaltiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super, merci Anne !
Voici mes commentaires,
En fait il s'agit surtout d'un bug de forcats.
Je t'ai mis le workaround, ça t'évitera bien des soucis.
Même en corrigeant le bug, on a un warning ggplot donc ça vaut toujours le coup de mettre un warning nous-mêmes pour être plus clairs et pour un plot plus joli.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nickel le nouveau fichier.
Essaie de séparer en plusieurs commits si tu peux : 1 commit ou tu bouges le code, et un commit ou tu ajoutes ta partie. Ca simplifie la review :-)

Comment on lines +45 to +48
expect_warning(
p <- waterfall_plot(data_na, warnings = TRUE),
regexp = "ignore"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarde mes appels à expect_warning() dans les autres fichiers : tu appelles la fonction et tu pipe ton expect.
En utilisant une classe plutôt qu'un regexp, ça nous laisse libre de changer le message sans avoir à changer le test, et ça évite une interaction avec un autre warning émis par une fonction interne et qui contiendrait "ignore"

Comment on lines +41 to +42
target_sum_diff_first = runif(n(), -0.6, 0.3),
target_sum_diff_first = replace(target_sum_diff_first, c(1, 3, 10), NA)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternativement, tu peux :

  • mettre NA dans x% des cas :
target_sum_diff_first = if_else(runif(n())<0.2, NA, target_sum_diff_first) # 20% de NA
  • mettre NA pour les x-ièmes lignes :
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

if(warnings) cli_warn("{.fun waterfall_plot} will ignore {na_y} observation{?s} with missing {.var {y}} and subjid : {.val { . $subjid[na_rows]}}.")
filter(., !is.na(y))
} else .
} %>%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • On essaie d'éviter les {} 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.
  • C'est en fait un bug de forcats, qu'on peut résoudre avec fct_reorder2(.na_rm=FALSE)
  • Sur l'objet qui en résulte (sans erreur), tu pourras facilement checker les NA et émettre ton warning
  • Ajoute une classe à ton warning (cf. mon commentaire dans les tests).
  • Est-ce qu'on veut vraiment enlever les NA de toutes les colonnes ? Par exemple, ça ne me choquerait pas d'avoir une réponse manquante, ça ajouterait juste une classe grise dans les couleurs.
  • Par contre si on ajoute des NA dans la réponse, l'ordre devient bizarre, on fait une autre issue ou tu veux essayer de réparer ?

@DanChaltiel DanChaltiel marked this pull request as draft December 8, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

waterfall_plot() bugs

2 participants