Skip to content

Expression evaluation of Plotting labels containing spaces

6 messages · Pascal Oettli, David Winsemius, Santosh

#
Hello,

Example not reproducible:

 > exc <- list(units=list( c(m^2)) ,vars= list(c('asb')), ,label= 
list(c('abs surf body')))

Error: object 'm' not found

Regards,
Pascal
On 05/06/13 11:39, Santosh wrote:
#
Hi,

On possibility is:

par(mfrow=c(2,1), mar=c(5.1,5.1,4.1,2.1))
plot(1,1, ylab=expression(a.s.b.~(m^2)))
plot(1,1, ylab=expression(abs~surf~body~(m^2)))

Regards,
Pascal
On 05/06/13 11:39, Santosh wrote:
#
On Jun 4, 2013, at 8:39 PM, Santosh wrote:

            
Mail client mangled this due entirely to your improper use HTML. You  
have been posting to Rhelp long enough to have had plenty of  
opportunity to read the Posting Guide. And I know for a fact that it  
is quite easy to send plain text using gmail. You have no legitimate  
excuse for continuing this deprecated practice.

Anyway,  running this code:

exc <- list(units=list( c("m^2")) ,vars= list(c('asb')), label=  
list(c('abs surf body')))
# Notice that I quoted the 'units' value
plot(1:10,1:10, ylab=parse(text= paste(exc$vars[1],'(',exc 
$units[1],')',sep='')))
# Also note that plotmath cannot handle embedded carriage returns
plot(1:10,1:10, ylab=parse(text= paste(exc$label[1],'(',exc 
$units[1],')',sep='')))

Produces this error:

Error in parse(text = paste(exc$label[1], "(", exc$units[1], ")", sep  
= "")) :
   <text>:1:5: unexpected symbol
1: abs surf
        ^
(You are asked in the Posting Guide exactly your code and also to post  
your error messages.)

So you are trying to parse an expression and the parser is expecting a  
comma or a tilde or  .... something other than the beginning of  
another token. You never said what you actually wanted (also a request  
in the Posting Guide),  but try adding tilde's:

exc <- list(units=list( c("m^2")) ,vars= list(c('asb')), label=  
list(c('abs~surf~body')))

plot(1:10,1:10, ylab=parse(text= paste(exc$vars[1],'(',exc 
$units[1],')',sep='')))

plot(1:10,1:10, ylab=parse(text= paste(exc$label[1],'(',exc 
$units[1],')',sep='')))

I know that the plotmath help page is not exactly the most expansive  
regarding how to form proper expressions for R but at least review it  
and run the examples:

?plotmath
#
Hello,

?plotmath -> See Also
demo(plotmath)

Regards,
Pascal
On 05/06/13 15:00, Santosh wrote: