1

I have not been successful in adding both pvalue from a Kendall correlation and R² from a linear model. I am using ggplot.

I tried using stat_fit_glance and stat_poly_eq but that didn't work, it showed the following warning messages:

Warning messages:

1. Computation failed in `stat_poly_eq()`:
object of type 'closure' is not subsettable 

2. Computation failed in `stat_fit_glance()`:
object of type 'closure' is not subsettable 

Then, I tried using ggscatter but then it couldn't find the y used. I also tried adding it manually, but it didn't work because my corr.test is not a data frame.

This is the code that I have so far (it's only the scatter plot)

seq15 %>% ggplot(aes(Fe, Cr, color=depth)) +
  geom_point() + xlab(expression(paste("Fe mg"~ kg^-1~"2015"))) + 
  ylab(expression(paste("Cr mg"~ kg^-1))) +
  geom_smooth(data = subset(seq15, profundidade %in% c("0-3")), method = lm, se = FALSE, colour = "black", size = 0.1) +
  scale_color_discrete(labels = c("0-3 cm", "3-5 cm", "5-10 cm", "10-15 cm", "15-20 cm", "20-25 cm", "25-30 cm")) +
  theme(panel.border = element_rect(colour = "black", fill = NA, size = 0.1),panel.background = element_blank(), axis.line = element_line(color="black"), axis.line.x = element_line(color="black"),legend.title = element_text(color = "white"), legend.key = element_rect(fill = NA))

And the correlation test:

cor.test(seq15$Fe,seq15$Cr, method = "kendall")
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0