[R] superscript characters in title with '+'

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Oct 26 20:15:11 CEST 2010


On Fri, 2010-10-22 at 15:39 +0200, Claudia Beleites wrote:
> On 10/22/2010 03:15 PM, DrCJones wrote:
<snip />
> 
> Being a chemist, it seemed natural to me to put the i after the concentration 
> brackets into a subscript - though you didn't say you want that.
> 
> A more "correct" expression would be:
> 
> group ("[", Ca^'2+', "]") [i]~onsets

You don't need to quote the 2+, but if you don't quote it you have to
give R's parser something to work with on the RHS of "+". phantom() is
useful in such cases:

plot(1:10, ylab = expression(group("[", Ca^{2+phantom()}, "]")[i]~onsets))

for example, produces similar output to your version. My preference is
to use fewer strings in these expressions, but then again my version
involves more typing. You pays your money... as they say.

G

> where you can easier see that the "[" and "]" are special left and right 
> delimiters. Note that the only term that needs to be "hidden" as character is 
> the charge, as R doesn't know this way of writing ion charges and supposes + to 
> be an infix operator.
> 
> 
> Cheers,
> 
> Claudia

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list