On Oct 22, 2010, at 7:01 AM, DrCJones wrote:>
> Hi,
>
> How can I get the '2+' into superscript in the following title:
>
> '[Ca2+]i onsets'
>
> I tried the command below, but it doesn't work. What am I missing?
The first is an unambiguous description of what you want, but here are
some guesses (since it was entirely confusing when above you put the
"i" after the rt-square-bracket, and below put it before the
"2+"):
expression("["*Ca*"]"*i^paste(2,"+")~'onsets')
expression("["*Ca*"]"^paste(2,"+")*i~'onsets')
If one of those guesses is correct then what you were missing was an
understanding of the differences between the plotmath syntax and
regular printing. The characters"[", "]", and "+"
are special so if
you just want them treated as ordinarily characters, you need to
surround them in quotes. If you want to put "2+" as superscript, the
plotmath paste function (not to be confused with the ordinary R
paste() ) will let you group sub-expressions. It would also be
possible to use the group() expression-function. And the final missing
piece is the knowledge that itmes in an expression are separated by
"*"'s and "~"'s rather than commas or spaces.
?plotmath # which I think does an inadequate job of describing the
features mentioned above.
If you need to insert values in expressions then: ?bquote or ?
substitute
Took me a couple of years to feel that I had a decent chance of
getting an expression correct on even the second or third try.
>
> hist(X, main=expression(([Ca*]i^2+) 'onsets'), xlab =
'sec')
>
>
David Winsemius, MD
West Hartford, CT