[R] text() with text, variables and math HOWTO?

Thomas Petzoldt thpe at hhbio.wasser.tu-dresden.de
Fri Aug 27 09:53:00 CEST 2004


Johannes Graumann wrote:
> Hello,
> 
> One more question from the 'abusing R for blotting - particularly
> anally' department:
> How can I in the expression below make the '%~~%' show up as the
> aprrox-sign I want it to be?
> 
> Thanks for any hint,

Your code does not work because "%~~%" is a character string and %~~% is 
an invalid mathematical expression. The operator (e.g. %~~%) must be 
between something, so it works if you use phantom(0)%~~%phantom(0), and 
I found that phantom() without 0 works too:

See the following:


plot(0, xlim=c(0,1000), ylim=c(0,2), type="n")

time1=99

text(
	500,1.5,
	cex=0.75,
	substitute(
		paste(
			OD[600][~nm],
			" of 1 at ",
			time1,
			" min ",
			phantom()%~~%phantom(),
			time1h,
			"h"
		),
		list(
			time1=round(time1,digits=0),
			time1h=round(time1/60,digits=1)
		)
       )
)

Hope it helps

Thomas P.




More information about the R-help mailing list