[R] how to print km square in the form of km2

Rolf Turner rolf.turner at xtra.co.nz
Tue Feb 21 01:24:56 CET 2012


On 21/02/12 12:54, Elaine Kuo wrote:
> Hello,
>
> This is Elaine.
>
> I am drawing a plot with x-axis label with "km square" as the unit.
> Now I want to print km square in the form of km2 and output "2" as the
> uppercase.
> Please kindly help suggest command to show the uppercase.

When you say "as [the] uppercase" I *think* you mean "as a
superscript".  Assuming that I am correct in my supposition,
you can achieve what you want via the syntax shown in the
following example:

     plot(1:10,ylab="y",xlab=expression(plain(km)^2))

For details on how you do this sort of thing in general see:

     ?plotmath

Be warned --- it's tricky!  I find that I always need to experiment
quite a lot before I get it right.  Experimentation is cheap, but.

HTH

     cheers,

         Rolf Turner



More information about the R-help mailing list