[R] Help using substitute and expression functions

Patrick Connolly p_connolly at slingshot.co.nz
Mon Jun 22 11:38:14 CEST 2009


I'm stopped at a browser in a loop where the following objects look
like this:

Browse[1]> jk
[1] 1
Browse[1]> leg.ab[jk]
[1] "Snails Rep1"
Browse[1]> top.k
[1] "LT95=7.5; LT99=8.8"

I can join them and a few other characters together like this easily
enough:

Browse[1]> paste(jk, ": ", leg.ab[jk], " [", top.k, "]", sep = "")
[1] "1: Snails Rep1 [LT95=7.5; LT99=8.8]"
Browse[1]> 


Now, suppose that instead of a simple character string for top.k, I
had an expression like this:

Browse[1]> leg.k.exp
expression(paste("LT"["95"] == 7.5, "; ", "LT"["99"] == 8.8))
Browse[1]> 

which was created in a slightly complicated loop joining the 95 and 99
bits together.  That code is designed to have a variable number of
those bits.

I tried using substitute(), bquote and expression() to join the
leg.k.exp object in with the other characters, but it always falls
over trying to parse the ":" character string instead of using it just
as a string.  I can see in the help for plot.math lots of ways of
adding mathematical symbols and Greeek letters, but nothing for what I
wish to do.  There's a trick or two I'm missing.

Apologies for the lack of specifics of what I've tried.  That's on
another computer inaccessible from this one, and that one doesn't have
a usable email client.

TIA


-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.




More information about the R-help mailing list