[R] help with expression

David Winsemius dwinsemius at comcast.net
Wed Mar 14 17:19:02 CET 2012


On Mar 14, 2012, at 11:53 AM, ilai wrote:

> On Wed, Mar 14, 2012 at 8:56 AM, Thomas Hoffmann
> <hoffmann at giub.uni-bonn.de> wrote:
>> Hi all,
>>
>> I still fail to plot an axis title with the following expression:
>>
>> plot(0,xlab=expression('(SOC [' * kgm^{-2} * '])' * ^{-2}))
>>
>> the xlab should look like:   (SOC [kgm^2])^0.25
>>
>> with an out bracket and a superscript.
>>
>
> Like this ?
> plot(0,xlab=expression(paste('(SOC[',kgm^-2,'])'^0.25,sep='')))

If so, then this is more simple:

plot(0,xlab=expression('(SOC['*kgm^-2*'])'^0.25))  # using * as a  
spaceless "connector"

And as far as I know, unlike the base R paste function, there is no  
sep argument in the plotmath paste function. Look what happens with:

plot(0,xlab=expression(paste('(SOC[',kgm^-2,'])'^0.25,sep='#')))

"#" not used as a separator above, but rather is appended at end

And:

plot(0,xlab=expression(paste('(SOC[',kgm^-2,'])'^0.25))) # no default  
space

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list