Re: [R] square brackets in expression in plots

2010-07-21 Thread Jannis
Dear Duncan, dear David,

thanks for the reply! I knew about Duncans solution, but could not figure out 
how to combine it that the 'm*s^-1' can be read from a string. Is there a way 
to tweak Davids suggestion in a way that this is possible?

E.g.:

a='m*s^-1'
b='speed~bgroup([,a, ])'
plot(1:10,main=parse(text=b)) 


Cheers
Jannis

--- David Winsemius dwinsem...@comcast.net schrieb am Di, 20.7.2010:

 Von: David Winsemius dwinsem...@comcast.net
 Betreff: Re: [R] square brackets in expression in plots
 An: Jannis bt_jan...@yahoo.de
 CC: r-h...@stat.math.ethz.ch
 Datum: Dienstag, 20. Juli, 2010 18:06 Uhr
 
 On Jul 20, 2010, at 12:42 PM, Jannis wrote:
 
  Dears,
  
  
  do you know whether it is possible to include any
 square parantheses (brackets) in an expression to use it as
 an axis label?
  
  e.g. I would like to have a label like (with the sub
 and superscripts correct):
  
  speed [m s^-1]
 
 Not exactly clear what you mean by correct.
  
  I know how to combine an expression with text via
 paste, but as I run soimething like:
  
  a='m*s^{-1}'
  plot(1:10,main=parse(text=a))
 
 ?plotmath
 
 This seemed to work fine with main, sub and xlab:
 
 a='speed [m*s^-1]'
  plot(1:10,main=parse(text=a))
 
 But maybe you wanted the square-brackets?
 
 a='speed~bgroup([, m*s^-1, ])'
 plot(1:10,main=parse(text=a))
 
  
  I found now way of doing this. I use the parse thing
 as I have all these units stored as strings that represent
 expressions.
  
  
  Cheers for any help!
  
  Jannis
  
  
  
  __
  R-help@r-project.org
 mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
 reproducible code.
 
 David Winsemius, MD
 West Hartford, CT
 
 



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] square brackets in expression in plots

2010-07-20 Thread Jannis
Dears,


do you know whether it is possible to include any square parantheses (brackets) 
in an expression to use it as an axis label?

e.g. I would like to have a label like (with the sub and superscripts correct):

speed [m s^-1]

I know how to combine an expression with text via paste, but as I run 
soimething like:

a='m*s^{-1}'
plot(1:10,main=parse(text=a))

I found now way of doing this. I use the parse thing as I have all these units 
stored as strings that represent expressions.


Cheers for any help!

Jannis



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] square brackets in expression in plots

2010-07-20 Thread David Winsemius


On Jul 20, 2010, at 12:42 PM, Jannis wrote:


Dears,


do you know whether it is possible to include any square parantheses  
(brackets) in an expression to use it as an axis label?


e.g. I would like to have a label like (with the sub and  
superscripts correct):


speed [m s^-1]


Not exactly clear what you mean by correct.


I know how to combine an expression with text via paste, but as I  
run soimething like:


a='m*s^{-1}'
plot(1:10,main=parse(text=a))


?plotmath

This seemed to work fine with main, sub and xlab:

a='speed [m*s^-1]'
 plot(1:10,main=parse(text=a))

But maybe you wanted the square-brackets?

a='speed~bgroup([, m*s^-1, ])'
plot(1:10,main=parse(text=a))



I found now way of doing this. I use the parse thing as I have all  
these units stored as strings that represent expressions.



Cheers for any help!

Jannis



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] square brackets in expression in plots

2010-07-20 Thread Duncan Murdoch

On 20/07/2010 12:42 PM, Jannis wrote:

Dears,


do you know whether it is possible to include any square parantheses (brackets) 
in an expression to use it as an axis label?

e.g. I would like to have a label like (with the sub and superscripts correct):

speed [m s^-1]

I know how to combine an expression with text via paste, but as I run 
soimething like:

a='m*s^{-1}'
plot(1:10,main=parse(text=a))

I found now way of doing this. I use the parse thing as I have all these units 
stored as strings that represent expressions.

  

plot(1,1, main=expression(paste(speed [, m * s^{-1}, ])))

Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.