[R] Pasting R code lines into labels

Marc Schwartz m@rc_@chw@rtz @end|ng |rom me@com
Thu Jun 6 17:40:12 CEST 2019

> On Jun 6, 2019, at 11:19 AM, Nick Wray via R-help <r-help using r-project.org> wrote:
> Is there any way of taking a line of r code (eg y<-x^2) and pasting that line of code, as is, into a label, so that for example I could then have a plot label "Plot of y<-x^2"?
> Thanks Nick Wray 


See ?plotmath

An example:

x <- 1:10
y <- x^2

plot(x, y, main = expression(paste("Plot of ", y %<-% x^2)))

There are other incantations and examples on the help page above.


Marc Schwartz

More information about the R-help mailing list