use_label() with kendall tau
I think I have encountered a bug for adding Kendall tau labels. I am trying to add Kendall's tau to scatterplots with the use_label() argument. This works for Pearson correlations and R2, however, when setting the method to "Kendall", the only stat I am able to successfully print is the P value. Attempting to print "tau" (or "R", "R.CI" which, is in the example documentation) returns this error:
Error in stat_correlation():
! Problem while converting geom to grob.
ℹ Error occurred in the 3rd layer.
Caused by error in parse():
!
This is code I am trying to use (I am using the ggpubr package, but this works for Pearson correlations)
myscatter <- data %>%
ggscatter(
x = "Age", y = "AUDIT_Total",
conf.int = TRUE,
title = "AUDIT",
ylab = "Total",
xlab = "Age",
cor.method = "kendall",
) +
stat_correlation(label.x= .1, mapping = use_label("tau", "p"), method = "kendall", vstep = 0.1, size = 10/.pt)
works on my end
library(ggpubr) library(ggpmisc) mtcars %>% ggscatter( x = "disp", y = "mpg", conf.int = TRUE, title = "AUDIT", ylab = "Total", xlab = "Age", cor.coef = TRUE, # Add correlation coefficient. see ?stat_cor cor.coeff.args = list(method = "kendall", label.x = 3, label.sep = "\n") )+ stat_correlation(label.x= .9, mapping = use_label("tau", "p"), method = "kendall", vstep = 0.1, size = 10/.pt)
Works also for me.