Open s-andrews opened 8 months ago
Hi, I got the same issue that is due to the fact that filtering occurs after positions have been computed. My current workaround is to explicitly set the comparisons.
data %>%
tukey_hsd(value~group) %>%
filter(p.adj<0.05) %>%
add_xy_position(comparisons = with(., Map(c, group1, group2))) -> stats_significant
diff(stats_significant$y.position)
There should be a better writing than my poor knowledge of tidyr.
@kassambara In add_y_position function, I think comparisons should be set before https://github.com/kassambara/rstatix/blob/360cda40bd22e80bce19ed63fbadfc4a9e52ce23/R/get_pvalue_position.R#L190 which should avoid the join/merge call.
If I want to plot the stats results for only the significant results from a stats test I can filter the output tibble before running
add_xy_position
, however this results in the y positions being spaced inconsistently rather than all the brackets being evenly separated.For example from the following data:
If I do a test on all groups and calculate the y position all values are equally spaced:
...and the plot shows equal spacing:
However if I filter for only significant results then I get unequal spacing:
..the plot is therefore also unequal
I should also note that the same effect exists if you use the
hide.ns
option tostat_pvalue_manual
but this is likely a different issue with a different fix.