What is reason Spearman Rank correlation is not come in gtsummary ?

I am using the gtsummary package to create summary tables and add p-values using add_p().

However, I noticed that Spearman rank correlation is not available as an option in add_p().

From my understanding:

  • add_p() provides tests like t-test, Wilcoxon, ANOVA, Kruskal–Wallis, chi-square, etc.
  • But it does not include correlation tests like Spearman or Pearson

I am trying to understand the reason behind this.

Hello!

add_p() includes only comparison tests between groups. For correlation coefficients or other statistical tests, you can use add_stat(). There you can specify a custom function (e.g. cor.test) and apply it to your desired variables. Check this out for more information :

Thanks so much for your helpful suggestion.

I understand that add_p() is mainly for group comparison tests, and for correlation analysis we should use add_stat() with a custom function like cor.test .

Right now, I am exploring gtsummary more deeply, and your guidance really helped me understand the correct approach. I will try implementing this in my analysis.

Thanks again for your support!

1 Like

Glad to help :slight_smile: and yes, i agree, gtsummary is a nice package for publication ready tables!