[R] superscript characters in title with '+'

Claudia Beleites cbeleites at units.it
Fri Oct 22 15:39:12 CEST 2010


On 10/22/2010 03:15 PM, DrCJones wrote:
>
> Hi, Thanks for all of your replies!
>
> David, a slightly modified version of what you gave did the trick:
>
> hist(X,main = expression("["*Ca**""^paste(2,"+")*"]i"~'onsets'))
here you put the 2+ into the superscript of a superscript.

compare these four:
hist(X,main = expression(Ca**2~Ca^2~Ca**""^2~Ca^""^2))

** and ^ both mean power

> But I prefer the way '2+' is italicized in the solution Dennis gave:
>
> hist(X, main = bquote('[Ca'^'2+'*']i'~'onsets'), xlab = 'sec')
>
> I think I understand it now - the '^' symbol must be followed by the '*'
> symbol to signify the end of font italicization;
no, the ^ is the power function infix operator, as in x^2 = x².
* is multiplication, but the multiplication is written without dot:
x * y = x ⋅ y = xy

It is abused here to connect terms into one expression.

and '~' must be used to
> signify spaces.
yes

>The only thing I still don't get is why square brackets
> rather than quotation marks surround the 'i' in the solution Claudia gave:
>
> hist(X, main=expression("[" * Ca^"2+" * "]" [i]~'onsets'),  xlab = 'sec')
the square bracket operator marks indices, which are written as subscript. So
x[i] produces what in LaTeX would be x_i

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

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



-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbeleites at units.it



More information about the R-help mailing list