Cannot use certain equation in stat_poly_eq

Create issue
Issue #21 closed
Former user created an issue

library(ggpmisc) ; formula <- E ~ 0 + I(VFtotal - 0.9) S_VFt_E_df_low %>% ggplot(aes(VFtotal, E)) + geom_point() + geom_smooth(method = lm, formula = formula) + stat_poly_eq(aes(label = paste(..eq.label.., ..adj.rr.label.., sep = "~~~~")), formula = formula, parse = T) + ggtitle("formula = E ~ 0 + I(VFtotal - 0.9)")

Warning messages: 1: Computation failed in stat_smooth(): object 'E' not found 2: Computation failed in stat_poly_eq(): object 'E' not found

The plot is obtained but without any fitting line.

Comments (1)

  1. Pedro J. Aphalo repo owner

    Model formulas need to be defined using the names of the aesthetics (x and y), rather than based on the names of mapped variables. This is how ggplot works, the code in geoms and stats has no direct access to the original names of the mapped variables. From your own example, it is clear that the behaviour of 'ggplot2' and 'ggpmisc' is the same, and as described.

  2. Log in to comment