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 :

1 Like

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!

2 Likes

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

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.