[R] superscript characters in title with '+'

David Winsemius dwinsemius at comcast.net
Tue Oct 26 20:35:07 CEST 2010


On Oct 26, 2010, at 11:15 AM, Gavin Simpson wrote:

> 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.

You could use doubled single quotes '' in the same position as that  
phantom(). Of course that mean means the net effect is just moving  
quotes around and probably not in the most intuitive manner.

-- 
David.
>
> 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
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list