0

How might I use plotmath capabilities to add a multiplicative Poisson-like equation to my plot? Or, given that I'm really close, how can I write this equation without the . in the middle of the exponent? I tried phantom but it didn't work (or I'm not using it correctly).

This is used in a looping process to make many plots, so having the ability to swap out the numbers and labels is key.

#   ---- Covariate names.
covar1 <- "var1"
covar2 <- "var2"

#   ---- Some numbers.  
beta0 <- 2.654
beta1 <- -0.084
beta2 <- 1.123

#   ---- A boring plot.  
plot(seq(0,100,1),seq(0,100,1))

#   ---- How to do this without the %.% ?
text(60,20,bquote(paste("Eqn: ","y = ",.(beta0),plain(e)^{.(beta1) %.% "X" [.(covar1)] + .(beta2) %.% "X" [.(covar2)] })))

This should be Eqn: y = 2.654e^{-0.084X_var1 + 1.123X_var2}.

How do I get rid of the dot?

How to get rid of the dots?

jasmyace
  • 101
  • 1
  • 7
  • 1
    The dots are being created by the `%.%`. Remove them and replace with `*` (the asterisk puts two elements together without a space between them). – eipi10 Oct 31 '18 at 16:30
  • And that works too: `text(60,20,bquote(paste("Eqn: ","y = ",.(beta0),plain(e)^{.(beta1) * "X" [.(covar1)] + .(beta2) * "X" [.(covar2)] })))` – jasmyace Oct 31 '18 at 16:38

1 Answers1

1

Sticking with it, here is one way -- reproduce the paste inside the braces.

#   ---- A boring plot.  
plot(seq(0,100,1),seq(0,100,1))

#   ---- How to do this.
text(60,20,bquote(paste("Eqn: ","y = ",.(beta0),plain(e)^{paste(.(beta1),X[.(covar1)] + .(beta2),X[.(covar2)])})))

enter image description here

jasmyace
  • 101
  • 1
  • 7