[R] Converting to subscripts and superscripts

Ben Bolker bolker at ufl.edu
Thu Jul 31 15:40:48 CEST 2008


 <naw3 <at> duke.edu> writes:

> 
> Hi,
> 
> I am reading in a CSV file of chemical reactions where the subscripts and
> superscripts are encoded in angle brackets, like below:
> 
> 2 H<SUP>+</SUP> + 2 O<SUB>2</SUB><SUP>-</SUP>
> 
> Is there a way to convert these to actual sub/superscripts and save them in
> another excel file? I greatly appreciate the help!
> 
> Thanks,
> -Nina
> 

  I don't think this is possible (or at least not easy).
What you're really asking for is an Excel filter; seems
to me the easiest (?) way to do this would be in Visual
Basic, or to do search and replace in your work sheet,
replacing <sup>2</sup> with (superscript)2, and so on
[it doesn't look like Excel's search-and-replace has
a regular expression facility, but if you only have
a few worksheets and a limited number of sub- and
superscripts (say sub/super 1,2,3,+,-) this shouldn't
be too painful ...

  Ben Bolker



More information about the R-help mailing list