eq.x.rhs apparently has no effect?

Create issue
Issue #4 resolved
Former user created an issue

The following MWE distills my experience using eq.x.rhs with stat_poly_eq. Perhaps I understand it incorrectly:

library(dplyr)
library(ggplot2)
library(ggpmisc)
formula  <- y~x
set.seed(1234)
data.frame(indep=10^(rnorm(1000))) %>%
  mutate(dep=10^(2.5 * log10(indep) + 0.6666 + rnorm(length(indep)))) %>%
  ggplot(aes(indep,dep)) +
  geom_point() +
  scale_x_log10() + scale_y_log10() +
  geom_smooth(method = "lm", formula = formula) +
  ggpmisc::stat_poly_eq(aes(label = ..eq.label..),
                        eq.with.lhs = "plain(log)[10](italic(y))~`=`~",
                        eq.x.rhs = "ANYTHING",
                        formula = formula,parse=TRUE)

sessionInfo(package='ggpmisc')
# ...
# other attached packages:
# [1] ggpmisc_0.2.13
# ...

(for those following at home, the equation reads 'log_10(y) = 0.683 + 2.56 x', where I expect the 'x' to be substituted.

Comments (3)

  1. Pedro J. Aphalo repo owner

    Resolved.

    library(dplyr)
    library(ggplot2)
    library(ggpmisc)
    formula  <- y~x
    set.seed(1234)
    data.frame(indep=10^(rnorm(1000))) %>%
      mutate(dep=10^(2.5 * log10(indep) + 0.6666 + rnorm(length(indep)))) %>%
      ggplot(aes(indep,dep)) +
      geom_point() +
      scale_x_log10() + scale_y_log10() +
      geom_smooth(method = "lm", formula = formula) +
      ggpmisc::stat_poly_eq(aes(label = ..eq.label..),
                            eq.with.lhs = "plain(log)[10](italic(y))~`=`~",
                            eq.x.rhs = "~italic(z)",
                            formula = formula,parse=TRUE)
    

    Rplot.png

  2. Log in to comment