[R] Plot title with numeric variables

Rene Braeckman RMan54 at cox.net
Tue Nov 14 22:39:38 CET 2006


Thanks for your quick response. This works but the problem is that I can't
define the title ahead before N is defined or changed.

The idea is that the title is defined ahead, passed to a function that makes
many plots, and N is incremented for each plot.

One way to accomplish this would be to have the constant part of the title
defined ahead:
> xxx <- bquote(bold("Plot"~C[max]~"versus CrCl"))

Bold is needed because the subscripted text "max" is too light (doesn't seem
to follow font changes) but I could leave it out if needed.

And then add this to the changing part at the time the plot is made (when
the value of N is correct).
The changing part is:
> ccc <- bquote(("Figure"~.(N))

I just don't know how to concatenate both xxx and ccc to create the title.

Thanks again,
Rene

-----Original Message-----
From: rolf at math.unb.ca [mailto:rolf at math.unb.ca] 
Sent: Tuesday, November 14, 2006 12:42 PM
To: RMan54 at cox.net
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Plot title with numeric variables

The key thing is the function bquote().

E.g.

	> N <- 5
	> xxx <- bquote(bold("Figure"~.(N)~"Plot"~C[max]~"versus CrCl"))
	> plot(1:10,main=xxx)

(Not sure about the ``bold'' business, but R doesn't object.)

Or to take a simpler and clearer example:

	> N <- 5
	> plot(1:10,main=bquote("Figure"~.(N))


				cheers,

					Rolf Turner
					rolf at math.unb.ca



More information about the R-help mailing list