Here is a version using basic graphics and ?plotmath to draw a graph and annotate it
#
Then calculate the values ββyou want to display in the annotation. I prefer bquote() for this, where everything that is marked in .(foo) will be replaced with the value of the foo object. @Mnel's answer indicates that substitute() used in the comments to achieve the same, but using different means. Therefore, I create objects in the workspace for each value that you might want to display in the annotation:
## Calculate RMSE and other values rmse <- round(sqrt(mean(resid(fit)^2)), 2) coefs <- coef(fit) b0 <- round(coefs[1], 2) b1 <- round(coefs[2],2) r2 <- round(summary(fit)$r.squared, 2)
Now create the equation using the constructs described in ?plotmath :
eqn <- bquote(italic(y) == .(b0) + .(b1)*italic(x) * "," ~~ r^2 == .(r2) * "," ~~ RMSE == .(rmse))
Once this is done, you can draw a plot and annotate it with your expression
#
What gives:

Gavin simpson
source share