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

Sarah Goslee sarah.goslee at gmail.com
Wed Feb 29 22:37:08 CET 2012


Try
plot(1:10,ylab="y",xlab=expression(km^2))
and if that fails, you'll need to tell us what you mean by "did not
work."

Sarah

On Wed, Feb 29, 2012 at 4:27 PM, Elaine Kuo <elaine.kuo.tw at gmail.com> wrote:
> Hello Rolf,
>
> Thank you for the response.
>
> I tried your command but it did not work.
>  plot(1:10,ylab="y",xlab=**expression(plain(km)^2))
>
> Please kindly advise any other method to make "2" in km2 become a uppercase
> number.
> Thanks again.
>
> Elaine
>
>
> On Tue, Feb 21, 2012 at 8:24 AM, Rolf Turner <rolf.turner at xtra.co.nz> wrote:
>
>> 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,
>>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list