Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Gabor Grothendieck
If you specifically want to know which packages were loaded by the script
then using a vanilla version of R (i.e. one where only base packages are
loaded):

  vanilla_search <- search()
  source("myRprg.R")
  setdiff(search(), vanilla_search)



On Wed, Jun 20, 2018 at 4:08 AM, Sigbert Klinke
 wrote:
> Hi,
>
> I have read an R program with
>
> expr <- parse("myRprg.R")
>
> How can I extract the parameters of a specifc R command, e.g. "library"?
>
> So, if myprg.R containes the lines
>
> library("xyz")
> library("abc")
>
> then I would like to get "xyz" and "abc" back from expr.
>
> Thanks in advance
>
> Sigbert
>
> --
> https://hu.berlin/sk
>
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Extract function parameters from a R expression

2018-06-20 Thread Bert Gunter
... or if the argument is just quoted text or a numeric value as in your
library() example, don't parse the text and use regex's to search for the
function call and pick out the text of the arguments.

Again, this only works (I think) for the simple sort of case of your
example. Beyond that, you'll have to follow Hadley's prescription.

Cheers,
Bert





Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Jun 20, 2018 at 1:26 AM, Hadley Wickham  wrote:

> You need to recursively walk the parse tree/AST. See, e.g.,
> https://adv-r.hadley.nz/expressions.html#ast-funs
>
> Hadley
>
> On Wed, Jun 20, 2018 at 10:08 AM, Sigbert Klinke
>  wrote:
> > Hi,
> >
> > I have read an R program with
> >
> > expr <- parse("myRprg.R")
> >
> > How can I extract the parameters of a specifc R command, e.g. "library"?
> >
> > So, if myprg.R containes the lines
> >
> > library("xyz")
> > library("abc")
> >
> > then I would like to get "xyz" and "abc" back from expr.
> >
> > Thanks in advance
> >
> > Sigbert
> >
> > --
> > https://hu.berlin/sk
> >
> >
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
> >
>
>
>
> --
> http://hadley.nz
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Extract function parameters from a R expression

2018-06-20 Thread Hadley Wickham
You need to recursively walk the parse tree/AST. See, e.g.,
https://adv-r.hadley.nz/expressions.html#ast-funs

Hadley

On Wed, Jun 20, 2018 at 10:08 AM, Sigbert Klinke
 wrote:
> Hi,
>
> I have read an R program with
>
> expr <- parse("myRprg.R")
>
> How can I extract the parameters of a specifc R command, e.g. "library"?
>
> So, if myprg.R containes the lines
>
> library("xyz")
> library("abc")
>
> then I would like to get "xyz" and "abc" back from expr.
>
> Thanks in advance
>
> Sigbert
>
> --
> https://hu.berlin/sk
>
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



-- 
http://hadley.nz

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Extract function parameters from a R expression

2018-06-20 Thread Sigbert Klinke

Hi,

I have read an R program with

expr <- parse("myRprg.R")

How can I extract the parameters of a specifc R command, e.g. "library"?

So, if myprg.R containes the lines

library("xyz")
library("abc")

then I would like to get "xyz" and "abc" back from expr.

Thanks in advance

Sigbert

--
https://hu.berlin/sk


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] expression input to a function

2016-05-04 Thread Duncan Murdoch

On 04/05/2016 7:11 AM, Naresh Gurbuxani wrote:

I am trying to write a function, which can be made very general if one of the 
inputs can be an expression.  How can this be done?


For example, to find root of a function, I would like to say

my.func <- function(x) {x^3 + 2 * (x^2) - 7}

x.left <- 0
x.right <- 2
n.iterations <- 0

find.root <- function(my.func, x.left, x.right) {
  # code here
return(c(x.mid, n.iterations))
}

The above method clearly does not work.


You are taking the right approach.  You can pass functions as arguments 
to other functions; they are "first class objects".  For example:


evaluate <- function(f, x) f(x)

evaluate(my.func, 3)

would give the same result as my.func(3).

For your find.root function, just write the search in find.root using 
the name of the argument (which for didactic purposes I'd recommend be 
different from the actual function name, but it'll be fine in practice).


It is also possible to pass expressions that aren't in functions, but it 
gets tricky, and you shouldn't do that in your first attempt.


Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] expression evaluation during recursion

2015-10-22 Thread david . kaethner

> You seem to have ignored my explanation.

True, sorry. Thanks for sticking with me. Making sense now.


> 
> Duncan Murdoch
> 
>> 
>> 
>>> Am 22.10.2015 um 19:05 schrieb Duncan Murdoch >> >:
>>> 
>>> On 22/10/2015 10:20 AM,david.kaeth...@gmail.com 
>>> wrote:
 Hello,
 
 I’m trying to solve an exercise, where I want to walk through the search 
 path recursively 
 (http://adv-r.had.co.nz/Environments.html).
 
 I’m puzzled by a certain behavior and hope somebody can give me an 
 explanation.
 
 This code works:
 
 listenv <- function(env = parent.frame()) {
 if (identical(env, emptyenv())) {
   #stop("reached emptyenv", call. = FALSE)
   return(env)
 } else {
   print(env)
   listenv(parent.env(env))
 }
 }
 
 Here, the calling environment is determined with a default parameter in 
 the function’s formals.
 
 However, if I want to assign the calling environment within the function’s 
 body, I get the error message „infinite recursion“. Also, I never get 
 actual environments (with attributes, that is), only memory addresses like 
 this: .
>>> 
>>> I'm not sure what you were looking for, but ""
>>> is the normal way to print an environment, unless it happens to be one
>>> of the special named ones (like .GlobalEnv).
>>> 
 
 listenv <- function(env) {
 env <- parent.frame()
 if (identical(env, emptyenv())) {
   #stop("reached emptyenv", call. = FALSE)
   return(env)
 } else {
   print(env)
   listenv(parent.env(env))
 }
 }
 
 Any explanation of what’s going on here would be greatly appreciated. I 
 suspect it has to do with when exactly the parent.frame()-expression is 
 evaluated, but that’s not an actual explanation.
>>> 
>>> 
>>> Your function completely ignores the "env" argument.  It never recurses.
>>> In the first case, "parent.frame()" is only a default value, so
>>> recursion happens properly.  If you change the first line in the body to
>>> these two lines
>>> 
>>> if (missing(env))
>>>   env <- parent.frame()
>>> 
>>> it would be equivalent.
>>> 
>>> Duncan Murdoch
>> 
> 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] expression evaluation during recursion

2015-10-22 Thread Duncan Murdoch

On 22/10/2015 2:44 PM, david.kaeth...@gmail.com wrote:

Hi,

I’m sure there’s a ton I don’t understand about environments, but I’m 
afraid your answer doesn’t make sense to me.


If it’s on the search path, the „print(env)“ should yield something like:


You never get to the search list.



attr(,"name")
[1] "package:pryr"
attr(,"path")
[1] "/Library/Frameworks/R.framework/Versions/3.2/Resources/library/pryr“

I agree that there would only be an address if it was an unnamed 
environment such as the ones constructed during function execution. 
But I’m walking the search path here, so these should all contain 
information on packages.


My question wasn’t so much about how to retrieve information on 
environments, there are plenty functions concerning that. I just don’t 
understand why it makes that much of a difference if I put the 
parent.frame() in the arguments list, or in the function body.


You seem to have ignored my explanation.

Duncan Murdoch




Am 22.10.2015 um 19:05 schrieb Duncan Murdoch 
>:


On 22/10/2015 10:20 AM,david.kaeth...@gmail.com 
wrote:

Hello,

I’m trying to solve an exercise, where I want to walk through the 
search path recursively 
(http://adv-r.had.co.nz/Environments.html).


I’m puzzled by a certain behavior and hope somebody can give me an 
explanation.


This code works:

listenv <- function(env = parent.frame()) {
 if (identical(env, emptyenv())) {
   #stop("reached emptyenv", call. = FALSE)
   return(env)
 } else {
   print(env)
   listenv(parent.env(env))
 }
}

Here, the calling environment is determined with a default parameter 
in the function’s formals.


However, if I want to assign the calling environment within the 
function’s body, I get the error message „infinite recursion“. Also, 
I never get actual environments (with attributes, that is), only 
memory addresses like this: .


I'm not sure what you were looking for, but ""
is the normal way to print an environment, unless it happens to be one
of the special named ones (like .GlobalEnv).



listenv <- function(env) {
 env <- parent.frame()
 if (identical(env, emptyenv())) {
   #stop("reached emptyenv", call. = FALSE)
   return(env)
 } else {
   print(env)
   listenv(parent.env(env))
 }
}

Any explanation of what’s going on here would be greatly 
appreciated. I suspect it has to do with when exactly the 
parent.frame()-expression is evaluated, but that’s not an actual 
explanation.



Your function completely ignores the "env" argument.  It never recurses.
In the first case, "parent.frame()" is only a default value, so
recursion happens properly.  If you change the first line in the body to
these two lines

 if (missing(env))
   env <- parent.frame()

it would be equivalent.

Duncan Murdoch




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] expression evaluation during recursion

2015-10-22 Thread david . kaethner
Hi,

I’m sure there’s a ton I don’t understand about environments, but I’m afraid 
your answer doesn’t make sense to me. 

If it’s on the search path, the „print(env)“ should yield something like:


attr(,"name")
[1] "package:pryr"
attr(,"path")
[1] "/Library/Frameworks/R.framework/Versions/3.2/Resources/library/pryr“

I agree that there would only be an address if it was an unnamed environment 
such as the ones constructed during function execution. But I’m walking the 
search path here, so these should all contain information on packages. 

My question wasn’t so much about how to retrieve information on environments, 
there are plenty functions concerning that. I just don’t understand why it 
makes that much of a difference if I put the parent.frame() in the arguments 
list, or in the function body.


> Am 22.10.2015 um 19:05 schrieb Duncan Murdoch :
> 
> On 22/10/2015 10:20 AM, david.kaeth...@gmail.com 
>  wrote:
>> Hello,
>> 
>> I’m trying to solve an exercise, where I want to walk through the search 
>> path recursively (http://adv-r.had.co.nz/Environments.html 
>>  
>> > >). 
>> 
>> I’m puzzled by a certain behavior and hope somebody can give me an 
>> explanation.
>> 
>> This code works:
>> 
>> listenv <- function(env = parent.frame()) {
>>  if (identical(env, emptyenv())) {
>>#stop("reached emptyenv", call. = FALSE)
>>return(env)
>>  } else {
>>print(env)
>>listenv(parent.env(env))
>>  }
>> }
>> 
>> Here, the calling environment is determined with a default parameter in the 
>> function’s formals. 
>> 
>> However, if I want to assign the calling environment within the function’s 
>> body, I get the error message „infinite recursion“. Also, I never get actual 
>> environments (with attributes, that is), only memory addresses like this: 
>> .
> 
> I'm not sure what you were looking for, but ""
> is the normal way to print an environment, unless it happens to be one
> of the special named ones (like .GlobalEnv).
> 
>> 
>> listenv <- function(env) {
>>  env <- parent.frame()
>>  if (identical(env, emptyenv())) {
>>#stop("reached emptyenv", call. = FALSE)
>>return(env)
>>  } else {
>>print(env)
>>listenv(parent.env(env))
>>  }
>> }
>> 
>> Any explanation of what’s going on here would be greatly appreciated. I 
>> suspect it has to do with when exactly the parent.frame()-expression is 
>> evaluated, but that’s not an actual explanation.
> 
> 
> Your function completely ignores the "env" argument.  It never recurses.
> In the first case, "parent.frame()" is only a default value, so
> recursion happens properly.  If you change the first line in the body to
> these two lines
> 
>  if (missing(env))
>env <- parent.frame()
> 
> it would be equivalent.
> 
> Duncan Murdoch


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] expression evaluation during recursion

2015-10-22 Thread david . kaethner
Hello,

I’m trying to solve an exercise, where I want to walk through the search path 
recursively (http://adv-r.had.co.nz/Environments.html 
). 

I’m puzzled by a certain behavior and hope somebody can give me an explanation.

This code works:

listenv <- function(env = parent.frame()) {
  if (identical(env, emptyenv())) {
#stop("reached emptyenv", call. = FALSE)
return(env)
  } else {
print(env)
listenv(parent.env(env))
  }
}

Here, the calling environment is determined with a default parameter in the 
function’s formals. 

However, if I want to assign the calling environment within the function’s 
body, I get the error message „infinite recursion“. Also, I never get actual 
environments (with attributes, that is), only memory addresses like this: 
. 

listenv <- function(env) {
  env <- parent.frame()
  if (identical(env, emptyenv())) {
#stop("reached emptyenv", call. = FALSE)
return(env)
  } else {
print(env)
listenv(parent.env(env))
  }
}

Any explanation of what’s going on here would be greatly appreciated. I suspect 
it has to do with when exactly the parent.frame()-expression is evaluated, but 
that’s not an actual explanation.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] expression evaluation during recursion

2015-10-22 Thread Duncan Murdoch
On 22/10/2015 10:20 AM, david.kaeth...@gmail.com wrote:
> Hello,
> 
> I’m trying to solve an exercise, where I want to walk through the search path 
> recursively (http://adv-r.had.co.nz/Environments.html 
> ). 
> 
> I’m puzzled by a certain behavior and hope somebody can give me an 
> explanation.
> 
> This code works:
> 
> listenv <- function(env = parent.frame()) {
>   if (identical(env, emptyenv())) {
> #stop("reached emptyenv", call. = FALSE)
> return(env)
>   } else {
> print(env)
> listenv(parent.env(env))
>   }
> }
> 
> Here, the calling environment is determined with a default parameter in the 
> function’s formals. 
> 
> However, if I want to assign the calling environment within the function’s 
> body, I get the error message „infinite recursion“. Also, I never get actual 
> environments (with attributes, that is), only memory addresses like this: 
> .

I'm not sure what you were looking for, but ""
is the normal way to print an environment, unless it happens to be one
of the special named ones (like .GlobalEnv).

> 
> listenv <- function(env) {
>   env <- parent.frame()
>   if (identical(env, emptyenv())) {
> #stop("reached emptyenv", call. = FALSE)
> return(env)
>   } else {
> print(env)
> listenv(parent.env(env))
>   }
> }
> 
> Any explanation of what’s going on here would be greatly appreciated. I 
> suspect it has to do with when exactly the parent.frame()-expression is 
> evaluated, but that’s not an actual explanation.


Your function completely ignores the "env" argument.  It never recurses.
 In the first case, "parent.frame()" is only a default value, so
recursion happens properly.  If you change the first line in the body to
these two lines

  if (missing(env))
env <- parent.frame()

it would be equivalent.

Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] expression in xlab for a plot

2014-01-01 Thread Andras Farkas
Dear All,

Happy new year!

wonder if you could help with the following:

we have:

hist(runif(1000,0,100),xlab=expression(AUC[0 - 24]~ (xyz)),ylab=Frequency)


the plan is to have part of the xlab expression change dynamically, 
specifically the values of 0 and 24 should be able to update 'automatically , 
based on vectors low and high, so if we had:
low -24
high -48
then we should have this:

hist(runif(1000,0,100),xlab=expression(AUC[24 - 48]~ (xyz)),ylab=Frequency)


appreciate your insights,

Andras

[[alternative HTML version deleted]]

__
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] expression in xlab for a plot

2014-01-01 Thread arun
Hi,May be this helps:


  hist(runif(1000,0,100),xlab=bquote(AUC[.(low) - .(high)]~ 
(xyz)),ylab=Frequency)
A.K.


On Wednesday, January 1, 2014 10:30 AM, Andras Farkas motyoc...@yahoo.com 
wrote:
Dear All,

Happy new year!

wonder if you could help with the following:

we have:

hist(runif(1000,0,100),xlab=expression(AUC[0 - 24]~ (xyz)),ylab=Frequency)


the plan is to have part of the xlab expression change dynamically, 
specifically the values of 0 and 24 should be able to update 'automatically , 
based on vectors low and high, so if we had:
low -24
high -48
then we should have this:

hist(runif(1000,0,100),xlab=expression(AUC[24 - 48]~ (xyz)),ylab=Frequency)


appreciate your insights,

Andras

    [[alternative HTML version deleted]]

__
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-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] expression in xlab for a plot

2014-01-01 Thread arun
HI,
Another way would be to use ?substitute()
hist(runif(1000,0,100),xlab=substitute(expression(AUC[low - high]~ 
(xyz)),list(low=low,high=high)),ylab=Frequency)
A.K.




On Wednesday, January 1, 2014 10:36 AM, arun smartpink...@yahoo.com wrote:
Hi,May be this helps:


  hist(runif(1000,0,100),xlab=bquote(AUC[.(low) - .(high)]~ 
(xyz)),ylab=Frequency)
A.K.



On Wednesday, January 1, 2014 10:30 AM, Andras Farkas motyoc...@yahoo.com 
wrote:
Dear All,

Happy new year!

wonder if you could help with the following:

we have:

hist(runif(1000,0,100),xlab=expression(AUC[0 - 24]~ (xyz)),ylab=Frequency)


the plan is to have part of the xlab expression change dynamically, 
specifically the values of 0 and 24 should be able to update 'automatically , 
based on vectors low and high, so if we had:
low -24
high -48
then we should have this:

hist(runif(1000,0,100),xlab=expression(AUC[24 - 48]~ (xyz)),ylab=Frequency)


appreciate your insights,

Andras

    [[alternative HTML version deleted]]

__
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-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] Expression evaluation of Plotting labels containing spaces

2013-06-05 Thread Santosh
Thanks so much!!
Would be it be better if in vignette of plotmath, x %~% y and x~~y;
likewise, other operations (.e.g.,
 x %*% y, x * y) may be grouped, so that are not missed by a layman like
me! - just a thought...

Thanks,
Santosh




On Tue, Jun 4, 2013 at 9:13 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Jun 4, 2013, at 8:39 PM, Santosh wrote:

  Dear Rxperts,
 How do I overcome the anomaly as in the second case of examples below?

 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='')))


 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

 --
 David.



 Thanks so much!

 Santosh

 [[alternative HTML version deleted]]


 Sigh.



 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html http://www.R-project.org/posting-guide.html

 ^^**^^**
 ^

  and provide commented, minimal, self-contained, reproducible code.



 ---
 David Winsemius, MD
 Alameda, CA, USA



[[alternative HTML version deleted]]

__
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] Expression evaluation of Plotting labels containing spaces

2013-06-05 Thread Pascal Oettli

Hello,

?plotmath - See Also
demo(plotmath)

Regards,
Pascal


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

Thanks so much!!
Would be it be better if in vignette of plotmath, x %~% y and x~~y;
likewise, other operations (.e.g.,
  x %*% y, x * y) may be grouped, so that are not missed by a layman like
me! - just a thought...

Thanks,
Santosh




On Tue, Jun 4, 2013 at 9:13 PM, David Winsemius dwinsem...@comcast.netwrote:



On Jun 4, 2013, at 8:39 PM, Santosh wrote:

  Dear Rxperts,

How do I overcome the anomaly as in the second case of examples below?

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='')))



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

--
David.




Thanks so much!

Santosh

 [[alternative HTML version deleted]]



Sigh.




R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/**
posting-guide.html http://www.R-project.org/posting-guide.html


^^**^^**
^

  and provide commented, minimal, self-contained, reproducible code.





---
David Winsemius, MD
Alameda, CA, USA




[[alternative HTML version deleted]]

__
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-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] Expression evaluation of Plotting labels containing spaces

2013-06-04 Thread Santosh
Dear Rxperts,
How do I overcome the anomaly as in the second case of examples below?

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='')))

Thanks so much!

Santosh

[[alternative HTML version deleted]]

__
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] Expression evaluation of Plotting labels containing spaces

2013-06-04 Thread Pascal Oettli

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:

Dear Rxperts,
How do I overcome the anomaly as in the second case of examples below?

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='')))

Thanks so much!

Santosh

[[alternative HTML version deleted]]

__
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-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] Expression evaluation of Plotting labels containing spaces

2013-06-04 Thread Pascal Oettli

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:

Dear Rxperts,
How do I overcome the anomaly as in the second case of examples below?

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='')))

Thanks so much!

Santosh

[[alternative HTML version deleted]]

__
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-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] Expression evaluation of Plotting labels containing spaces

2013-06-04 Thread David Winsemius


On Jun 4, 2013, at 8:39 PM, Santosh wrote:


Dear Rxperts,
How do I overcome the anomaly as in the second case of examples below?

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='')))


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

--
David.



Thanks so much!

Santosh

[[alternative HTML version deleted]]


Sigh.



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
Alameda, CA, USA

__
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] expression

2013-04-01 Thread Jose Narillos de Santos
Hi all,

I´m using


titt- expression(paste(R con ventanas de 200 , italic(datos)))

And it works properly on a plot(...,main=titt,..)

But if I want to add an improvement to avoid typing n on the plot so that

n-200

titt- expression(paste(R con ventanas de ,n,  italic(datos)))

It doesn´t recognize that n is a variable and adds n letter instead of
200 on the plot when run:

plot(...,main=titt,..)

How can I include n in the plot authomatically without loosing the italic
letter?

[[alternative HTML version deleted]]

__
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] expression

2013-04-01 Thread Bert Gunter
?plotmath

tells you how.

-- Bert

On Mon, Apr 1, 2013 at 12:46 PM, Jose Narillos de Santos
narillosdesan...@gmail.com wrote:
 Hi all,

 I惴 using


 titt- expression(paste(R con ventanas de 200 , italic(datos)))

 And it works properly on a plot(...,main=titt,..)

 But if I want to add an improvement to avoid typing n on the plot so that

 n-200

 titt- expression(paste(R con ventanas de ,n,  italic(datos)))

 It doesn愒 recognize that n is a variable and adds n letter instead of
 200 on the plot when run:

 plot(...,main=titt,..)

 How can I include n in the plot authomatically without loosing the italic
 letter?

 [[alternative HTML version deleted]]


 __
 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.




-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
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] expression

2013-04-01 Thread William Dunlap
Use bquote(), as in
  n - 200
  titt - bquote(paste(R con ventanas de , .(n),  , italic(datos)))
or, using ~ instead of paste(),
  titt - bquote(R con ventanas de  ~ .(n) ~ italic(datos))
  plot(1, 1, main=titt) 

The notation .(xxx) means to replace xxx by the value of the variable called 
xxx.

You can also use bquote() instead of expression in the simple (no variables) 
case.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Jose Narillos de Santos
 Sent: Monday, April 01, 2013 12:46 PM
 To: r-help
 Subject: [R] expression
 
 Hi all,
 
 I´m using
 
 
 titt- expression(paste(R con ventanas de 200 , italic(datos)))
 
 And it works properly on a plot(...,main=titt,..)
 
 But if I want to add an improvement to avoid typing n on the plot so that
 
 n-200
 
 titt- expression(paste(R con ventanas de ,n,  italic(datos)))
 
 It doesn´t recognize that n is a variable and adds n letter instead of
 200 on the plot when run:
 
 plot(...,main=titt,..)
 
 How can I include n in the plot authomatically without loosing the italic
 letter?
 
   [[alternative HTML version deleted]]

__
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] expression

2013-04-01 Thread Peter Ehlers

On 2013-04-01 12:46, Jose Narillos de Santos wrote:

Hi all,

I´m using


titt- expression(paste(R con ventanas de 200 , italic(datos)))

And it works properly on a plot(...,main=titt,..)

But if I want to add an improvement to avoid typing n on the plot so that

n-200

titt- expression(paste(R con ventanas de ,n,  italic(datos)))

It doesn´t recognize that n is a variable and adds n letter instead of
200 on the plot when run:

plot(...,main=titt,..)

How can I include n in the plot authomatically without loosing the italic
letter?


titt - bquote(R con ventanas de  ~ .(n) ~ italic(datos))

and I usually find it much more flexible to add the title with a
separate title(titt) call.

Peter Ehlers

__
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] expression exponent labeling

2013-03-13 Thread Berry Boessenkool


Hi all,

I want to label an axis with exponents, but can't get it done with expression.
Any hints would be very welcome!

# simulated data, somewhat similarly distributed to my real data:
set.seed(12); d - rbeta(1e6, 0.2,2)*150 ; d - d[d1e-8]
hist( d  , breaks=100)
# now on a logarithmically scaled axis:
hist(log10(d), breaks=100, xaxt=n)
abline(v= log10(1:10*10^rep(-9:3, each=10)), col=darkgrey ); box()
hist(log10(d), breaks=100, col=forestgreen, add=T)
axis(1, log10(1:10*10^rep(-9:3, each=10)), labels=F)
axis(1, -2:2, format(10^(-2:2), scient=3, drop0trailing=T) )
# the labels with lower values should be in the form of 10^x:
axis(1, -8:-3, expression( 10^(-8:-3)) )# doesn't work, because expression 
returns only one output
for(i in -8:-3) axis(1, i, expression(10^i)  ) # writes i at all locations

expression does exactly what it should, but I want something different here...
I've tried I(10^i) instead, but that's not right either.

Thanks ahead,
Berry


  
__
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] expression exponent labeling

2013-03-13 Thread Gerrit Eichner

Hi, Berry,

I think


for(i in -8:-3) axis(1, i, substitute(10^j, list( j = i)))


achieves what you want.

 Regards --  Gerrit


On Wed, 13 Mar 2013, Berry Boessenkool wrote:




Hi all,

I want to label an axis with exponents, but can't get it done with expression.
Any hints would be very welcome!

# simulated data, somewhat similarly distributed to my real data:
set.seed(12); d - rbeta(1e6, 0.2,2)*150 ; d - d[d1e-8]
hist( d  , breaks=100)
# now on a logarithmically scaled axis:
hist(log10(d), breaks=100, xaxt=n)
abline(v= log10(1:10*10^rep(-9:3, each=10)), col=darkgrey ); box()
hist(log10(d), breaks=100, col=forestgreen, add=T)
axis(1, log10(1:10*10^rep(-9:3, each=10)), labels=F)
axis(1, -2:2, format(10^(-2:2), scient=3, drop0trailing=T) )
# the labels with lower values should be in the form of 10^x:
axis(1, -8:-3, expression( 10^(-8:-3)) )# doesn't work, because expression 
returns only one output
for(i in -8:-3) axis(1, i, expression(10^i)  ) # writes i at all locations

expression does exactly what it should, but I want something different here...
I've tried I(10^i) instead, but that's not right either.

Thanks ahead,
Berry



__
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-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] expression exponent labeling

2013-03-13 Thread Peter Ehlers

On 2013-03-13 06:37, Gerrit Eichner wrote:

Hi, Berry,

I think


for(i in -8:-3) axis(1, i, substitute(10^j, list( j = i)))


achieves what you want.

   Regards --  Gerrit


Here's another (really no different) solution:

 for(i in -8:-3) axis(1, i, bquote(10^.(i)))

For more flexibility, if you need to do this a lot, you could
create an expression vector:

 x - -8:-3
 z - vector(expression, 6)
 for(i in 1:6) z[[i]] - bquote(10^.(x[i]))
 axis(1, x, z)

Peter Ehlers



On Wed, 13 Mar 2013, Berry Boessenkool wrote:




Hi all,

I want to label an axis with exponents, but can't get it done with expression.
Any hints would be very welcome!

# simulated data, somewhat similarly distributed to my real data:
set.seed(12); d - rbeta(1e6, 0.2,2)*150 ; d - d[d1e-8]
hist( d  , breaks=100)
# now on a logarithmically scaled axis:
hist(log10(d), breaks=100, xaxt=n)
abline(v= log10(1:10*10^rep(-9:3, each=10)), col=darkgrey ); box()
hist(log10(d), breaks=100, col=forestgreen, add=T)
axis(1, log10(1:10*10^rep(-9:3, each=10)), labels=F)
axis(1, -2:2, format(10^(-2:2), scient=3, drop0trailing=T) )
# the labels with lower values should be in the form of 10^x:
axis(1, -8:-3, expression( 10^(-8:-3)) )# doesn't work, because expression 
returns only one output
for(i in -8:-3) axis(1, i, expression(10^i)  ) # writes i at all locations

expression does exactly what it should, but I want something different here...
I've tried I(10^i) instead, but that's not right either.

Thanks ahead,
Berry



__
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] Expression in legend of plot

2012-10-25 Thread stat.kk
I would like to have an expression f^(-1)(x) in a legend of plot. For this I
used expression(f^{-1}(x)), but  variable is always in exponent. How could I
change it in order to (x) be in a line, not in exponent?
Thank you for your responses!



--
View this message in context: 
http://r.789695.n4.nabble.com/Expression-in-legend-of-plot-tp4647393.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Expression in legend of plot

2012-10-25 Thread Rui Barradas

Hello,

Use an asterisk to put a space between the exponent an (x).

plot(1, main =  expression(f^{-1}*(x)))

Hope this helps,

Rui Barradas
Em 25-10-2012 12:21, stat.kk escreveu:

I would like to have an expression f^(-1)(x) in a legend of plot. For this I
used expression(f^{-1}(x)), but  variable is always in exponent. How could I
change it in order to (x) be in a line, not in exponent?
Thank you for your responses!



--
View this message in context: 
http://r.789695.n4.nabble.com/Expression-in-legend-of-plot-tp4647393.html
Sent from the R help mailing list archive at Nabble.com.

__
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-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] Expression in legend of plot

2012-10-25 Thread Bert Gunter
... and note that the { ,} are unnecessary:

 plot(1, main =  bquote(f^-1*(x)))

-- Bert

On Thu, Oct 25, 2012 at 4:32 AM, Rui Barradas ruipbarra...@sapo.pt wrote:
 Hello,

 Use an asterisk to put a space between the exponent an (x).

 plot(1, main =  expression(f^{-1}*(x)))

 Hope this helps,

 Rui Barradas
 Em 25-10-2012 12:21, stat.kk escreveu:

 I would like to have an expression f^(-1)(x) in a legend of plot. For this
 I
 used expression(f^{-1}(x)), but  variable is always in exponent. How could
 I
 change it in order to (x) be in a line, not in exponent?
 Thank you for your responses!



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Expression-in-legend-of-plot-tp4647393.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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-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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
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] Expression in legend of plot

2012-10-25 Thread stat.kk
So easy solution..., thank you very much :)



--
View this message in context: 
http://r.789695.n4.nabble.com/Expression-in-legend-of-plot-tp4647393p4647397.html
Sent from the R help mailing list archive at Nabble.com.

__
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] expression() and font.lab ?

2012-04-27 Thread aparna15
Hi..

I managed to use expression() for superscripting and subscripting values in
my axis labels. However, I notice that the font and style that I had passed
through par() are ignored. 

I used :
par(font.lab=2, font=2, family=sans)

but when I employ expression() for my xlab, the styling given above is
completely ignored.

I would greatly appreciate it if someone knew of a method of maintaing the
style while superscripting or subscripting in an axis label.

Regards,
Aparna.


--
View this message in context: 
http://r.789695.n4.nabble.com/expression-and-font-lab-tp4592991p4592991.html
Sent from the R help mailing list archive at Nabble.com.

__
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] expression() and font.lab ?

2012-04-27 Thread David Winsemius


On Apr 27, 2012, at 11:22 AM, aparna15 wrote:


Hi..

I managed to use expression() for superscripting and subscripting  
values in

my axis labels.


What's missing here is your plotting code and your machine and R  
installation details. You may want to review the Posting Guide for  
what is requested. Plotting issues are more machine dependent than  
other aspects. Since the ?plotmath page does have details that include:


The fonts used are taken from the current font family, and so can be  
set by par(family=) in base graphics, and gpar(fontfamily=) in package  
grid.


Note that bold, italic and bolditalic do not apply to symbols, and  
hence not to the Greek symbols such as mu which are displayed in the  
symbol font. They also do not apply to numeric constants.


... my speculation is that you may not be using base graphics or you  
may have excessive expectations regarding how symbols are displayed.  
You can sometimes get around that last limitation by using character  
values where you want numeric values in bold or italic. Again, we need  
full details. Put together a reproducible example and repost.


--
David



However, I notice that the font and style that I had passed
through par() are ignored.

I used :
par(font.lab=2, font=2, family=sans)

but when I employ expression() for my xlab, the styling given above is
completely ignored.

I would greatly appreciate it if someone knew of a method of  
maintaing the

style while superscripting or subscripting in an axis label.

Regards,
Aparna.


--
View this message in context: 
http://r.789695.n4.nabble.com/expression-and-font-lab-tp4592991p4592991.html
Sent from the R help mailing list archive at Nabble.com.

__
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] expression() and font.lab ?

2012-04-27 Thread Aparna Radhakrishnan
Hi...sorry that my question seemed incomplete.

The plotting code :
par(cex.axis=0.8,las=1,font.lab=2,font.axis=2,family=sans,mgp=c(2,1,0),mar=c(3,
 3, 4, 2)+0.1)
plot(A$pos,-log(A$GPVI_frequentist_add_Batch_expected_pvalue,10),col=A$R2class,pch=A$pch,xlim=c(161160087,161214038),ylim=c(0,7),xlab=Genomic
 position,ylab=expression(-log[10]~(P-value)))

I am using a MacBook Pro and I have the R 2.15.0 . I have used only the 
base-graphics and not loaded any other libraries.

Hope that completes the question.

Please also find the plot attached here. Note the y-axis label is not in bold 
face or in sans font.

Regards,
Aparna.


On 27 Apr 2012, at 19:36, David Winsemius wrote:

 
 On Apr 27, 2012, at 11:22 AM, aparna15 wrote:
 
 Hi..
 
 I managed to use expression() for superscripting and subscripting values in
 my axis labels.
 
 What's missing here is your plotting code and your machine and R installation 
 details. You may want to review the Posting Guide for what is requested. 
 Plotting issues are more machine dependent than other aspects. Since the 
 ?plotmath page does have details that include:
 
 The fonts used are taken from the current font family, and so can be set by 
 par(family=) in base graphics, and gpar(fontfamily=) in package grid.
 
 Note that bold, italic and bolditalic do not apply to symbols, and hence not 
 to the Greek symbols such as mu which are displayed in the symbol font. They 
 also do not apply to numeric constants.
 
 ... my speculation is that you may not be using base graphics or you may have 
 excessive expectations regarding how symbols are displayed. You can sometimes 
 get around that last limitation by using character values where you want 
 numeric values in bold or italic. Again, we need full details. Put together a 
 reproducible example and repost.
 
 -- 
 David
 
 
 However, I notice that the font and style that I had passed
 through par() are ignored.
 
 I used :
 par(font.lab=2, font=2, family=sans)
 
 but when I employ expression() for my xlab, the styling given above is
 completely ignored.
 
 I would greatly appreciate it if someone knew of a method of maintaing the
 style while superscripting or subscripting in an axis label.
 
 Regards,
 Aparna.
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/expression-and-font-lab-tp4592991p4592991.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 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] expression() and font.lab ?

2012-04-27 Thread David Winsemius

converted formated text to plain text.
On Apr 27, 2012, at 3:52 PM, Aparna Radhakrishnan wrote:


Hi...sorry that my question seemed incomplete.

The plotting code :
par
(cex
.axis
=
0.8,las=1,font.lab=2,font.axis=2,family=sans,mgp=c(2,1,0),mar=c(3,  
3, 4, 2)+0.1)
plot(A$pos,-log(A$GPVI_frequentist_add_Batch_expected_pvalue, 
10),col=A$R2class,pch=A 
$pch,xlim=c(161160087,161214038),ylim=c(0,7),xlab=Genomic  
position,ylab=expression(-log[10]~(P-value)))




Well, since you didn't give the data, most of that plot argument is  
superfluous. Lets just use plot(1,1) as out staring point.  Plotmath  
expression interpetation of the font choices among plain, bold and  
italic are controlled by plotmath functions, so:


plot(1,1, ylab=expression( bold(-log[10]~(P-value) ) ) )

Now, thinking as the plotmath interpreter which considers - to be  
meaningful and then back as a human interpreter, I would suggest that  
you also consider whether this is what you really wanted:


plot(1,1, ylab=expression(bold(-log[10]~(P*-*value))) ) # no spaces  
fore and aft of the minus sign


Noting that one needs to quote the minus sing to prevent its  
interpretation as as minus sign. Or perhaps (thinking now as a human- 
plotmath hybrid):


plot(1,1, ylab=expression(bold(-log[bold(10)]~(P*-*value))) )


(Note that I suggested earlier that there _was_ a way to get numbers  
bold()-ed.)


--
David.

I am using a MacBook Pro and I have the R 2.15.0 . I have used only  
the base-graphics and not loaded any other libraries.


Hope that completes the question.

Please also find the plot attached here. Note the y-axis label is  
not in bold face or in sans font.


Regards,
Aparna.

FCER1G_locus_association.jpeg
On 27 Apr 2012, at 19:36, David Winsemius wrote:



On Apr 27, 2012, at 11:22 AM, aparna15 wrote:


Hi..

I managed to use expression() for superscripting and subscripting  
values in

my axis labels.


What's missing here is your plotting code and your machine and R  
installation details. You may want to review the Posting Guide for  
what is requested. Plotting issues are more machine dependent than  
other aspects. Since the ?plotmath page does have details that  
include:


The fonts used are taken from the current font family, and so can  
be set by par(family=) in base graphics, and gpar(fontfamily=) in  
package grid.


Note that bold, italic and bolditalic do not apply to symbols, and  
hence not to the Greek symbols such as mu which are displayed in  
the symbol font. They also do not apply to numeric constants.


... my speculation is that you may not be using base graphics or  
you may have excessive expectations regarding how symbols are  
displayed. You can sometimes get around that last limitation by  
using character values where you want numeric values in bold or  
italic. Again, we need full details. Put together a reproducible  
example and repost.


--
David



However, I notice that the font and style that I had passed
through par() are ignored.

I used :
par(font.lab=2, font=2, family=sans)

but when I employ expression() for my xlab, the styling given  
above is

completely ignored.

I would greatly appreciate it if someone knew of a method of  
maintaing the

style while superscripting or subscripting in an axis label.

Regards,
Aparna.








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] expression() and font.lab ?

2012-04-27 Thread Hermes
Thank you David.

Regards,
Aparna



On 27 Apr 2012, at 22:44, David Winsemius dwinsem...@comcast.net wrote:

 converted formated text to plain text.
 On Apr 27, 2012, at 3:52 PM, Aparna Radhakrishnan wrote:
 
 Hi...sorry that my question seemed incomplete.
 
 The plotting code :
 par
 (cex
 .axis
 =
 0.8,las=1,font.lab=2,font.axis=2,family=sans,mgp=c(2,1,0),mar=c(3, 3, 4, 
 2)+0.1)
 plot(A$pos,-log(A$GPVI_frequentist_add_Batch_expected_pvalue,10),col=A$R2class,pch=A$pch,xlim=c(161160087,161214038),ylim=c(0,7),xlab=Genomic
  position,ylab=expression(-log[10]~(P-value)))
 
 
 Well, since you didn't give the data, most of that plot argument is 
 superfluous. Lets just use plot(1,1) as out staring point.  Plotmath 
 expression interpetation of the font choices among plain, bold and italic are 
 controlled by plotmath functions, so:
 
 plot(1,1, ylab=expression( bold(-log[10]~(P-value) ) ) )
 
 Now, thinking as the plotmath interpreter which considers - to be 
 meaningful and then back as a human interpreter, I would suggest that you 
 also consider whether this is what you really wanted:
 
 plot(1,1, ylab=expression(bold(-log[10]~(P*-*value))) ) # no spaces fore 
 and aft of the minus sign
 
 Noting that one needs to quote the minus sing to prevent its interpretation 
 as as minus sign. Or perhaps (thinking now as a human-plotmath hybrid):
 
 plot(1,1, ylab=expression(bold(-log[bold(10)]~(P*-*value))) )
 
 
 (Note that I suggested earlier that there _was_ a way to get numbers 
 bold()-ed.)
 
 -- 
 David.
 
 I am using a MacBook Pro and I have the R 2.15.0 . I have used only the 
 base-graphics and not loaded any other libraries.
 
 Hope that completes the question.
 
 Please also find the plot attached here. Note the y-axis label is not in 
 bold face or in sans font.
 
 Regards,
 Aparna.
 
 FCER1G_locus_association.jpeg
 On 27 Apr 2012, at 19:36, David Winsemius wrote:
 
 
 On Apr 27, 2012, at 11:22 AM, aparna15 wrote:
 
 Hi..
 
 I managed to use expression() for superscripting and subscripting values in
 my axis labels.
 
 What's missing here is your plotting code and your machine and R 
 installation details. You may want to review the Posting Guide for what is 
 requested. Plotting issues are more machine dependent than other aspects. 
 Since the ?plotmath page does have details that include:
 
 The fonts used are taken from the current font family, and so can be set 
 by par(family=) in base graphics, and gpar(fontfamily=) in package grid.
 
 Note that bold, italic and bolditalic do not apply to symbols, and hence 
 not to the Greek symbols such as mu which are displayed in the symbol font. 
 They also do not apply to numeric constants.
 
 ... my speculation is that you may not be using base graphics or you may 
 have excessive expectations regarding how symbols are displayed. You can 
 sometimes get around that last limitation by using character values where 
 you want numeric values in bold or italic. Again, we need full details. Put 
 together a reproducible example and repost.
 
 -- 
 David
 
 
 However, I notice that the font and style that I had passed
 through par() are ignored.
 
 I used :
 par(font.lab=2, font=2, family=sans)
 
 but when I employ expression() for my xlab, the styling given above is
 completely ignored.
 
 I would greatly appreciate it if someone knew of a method of maintaing the
 style while superscripting or subscripting in an axis label.
 
 Regards,
 Aparna.
 
 
 
 
 
 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] expression set (Bioconductor) problem

2011-10-09 Thread Juliet Hannah
Note that exprs returns a matrix, so we can manipulate that just as we
would for any other type of matrix. There is also a Bioconductor
mailing list, which may be helpful.

On Thu, Oct 6, 2011 at 4:56 AM, Clayton K Collings ccoll...@purdue.edu wrote:
 Hello R people,

dim(exprs(estrogenrma)

 I have an expressionSet with 8 samples and 12695 features (genes)


 estrogenrma$estrogen
  present present absent absent present present absent absent
 estrogenrma$time.h
  10 10 10 10 48 48 48 48

 present - grep(present, as.character(estrogenrma$estrogen))
 absent  - grep(absent, as.character(estrogenrma$estrogen))
 ten - grep(10, as.character(estrogenrma$time.h))
 fortyeight  - grep(48, as.character(estrogenrma$time.h))

 present.10 - estrogenrma[, intersect(present, ten)]
 present.48 - estrogenrma[, intersect(present, fortyeight)]
 absent.10 - estrogenrma[, intersect(absent, ten)]
 absent.48 - estrogenrma[, intersect(absent, fortyeight)]


 present.10, present.48, absent.10, and absent.48 are four expression sets
 with two samples and 12695 features.

 How can I make a new 2 new expressionsets, each have 12695 features and one 
 sample
 where
 expressionset1 = (present.10 + present.48) / 2
 expressionset2 = (absent.10 + absent.48) / 2
 ?

 Thanks,
 Clayton

 - Original Message -
 From: Tal Galili tal.gal...@gmail.com
 To: SML paral...@lafn.org
 Cc: r-help@r-project.org
 Sent: Thursday, October 6, 2011 4:09:43 AM
 Subject: Re: [R] Mean(s) from values in different row?

 One way for doing it would be to combine the columns using paste and then
 use tapply to get the means.

 For example:

 set.seed(32341)
 a1 = sample(c(a,b), 100,replace = T)
 a2 = sample(c(a,b), 100,replace = T)
 y = rnorm(100)
 tapply(y,paste(a1,a2), mean)



 Contact
 Details:---
 Contact me: tal.gal...@gmail.com |  972-52-7275845
 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
 www.r-statistics.com (English)
 --




 On Thu, Oct 6, 2011 at 8:40 AM, SML paral...@lafn.org wrote:

 Hello:

 Is there a way to get a mean from values stored in different rows?

 The data looks like this:
  YEAR-1, JAN, FEB, ..., DEC
  YEAR-2, JAN, FEB, ..., DEC
  YEAR-3, JAN, FEB, ..., DEC

 What I want is the mean(s) for just the consecutive winter months:
  YEAR-1.DEC, YEAR-2.JAN, YEAR-2.FEB
  YEAR-2.DEC, YEAR-3.JAN, YEAR-3.FEB
  etc.

 Thanks.

 __
 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.


        [[alternative HTML version deleted]]

 __
 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-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-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] expression set (Bioconductor) problem

2011-10-06 Thread Clayton K Collings
Hello R people,

dim(exprs(estrogenrma)

I have an expressionSet with 8 samples and 12695 features (genes)


 estrogenrma$estrogen
  present present absent absent present present absent absent
 estrogenrma$time.h
  10 10 10 10 48 48 48 48

present - grep(present, as.character(estrogenrma$estrogen))
absent  - grep(absent, as.character(estrogenrma$estrogen))
ten - grep(10, as.character(estrogenrma$time.h))
fortyeight  - grep(48, as.character(estrogenrma$time.h))

present.10 - estrogenrma[, intersect(present, ten)]
present.48 - estrogenrma[, intersect(present, fortyeight)]
absent.10 - estrogenrma[, intersect(absent, ten)]
absent.48 - estrogenrma[, intersect(absent, fortyeight)]


present.10, present.48, absent.10, and absent.48 are four expression sets
with two samples and 12695 features.

How can I make a new 2 new expressionsets, each have 12695 features and one 
sample
where 
expressionset1 = (present.10 + present.48) / 2
expressionset2 = (absent.10 + absent.48) / 2
?

Thanks,
Clayton

- Original Message -
From: Tal Galili tal.gal...@gmail.com
To: SML paral...@lafn.org
Cc: r-help@r-project.org
Sent: Thursday, October 6, 2011 4:09:43 AM
Subject: Re: [R] Mean(s) from values in different row?

One way for doing it would be to combine the columns using paste and then
use tapply to get the means.

For example:

set.seed(32341)
a1 = sample(c(a,b), 100,replace = T)
a2 = sample(c(a,b), 100,replace = T)
y = rnorm(100)
tapply(y,paste(a1,a2), mean)



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Oct 6, 2011 at 8:40 AM, SML paral...@lafn.org wrote:

 Hello:

 Is there a way to get a mean from values stored in different rows?

 The data looks like this:
  YEAR-1, JAN, FEB, ..., DEC
  YEAR-2, JAN, FEB, ..., DEC
  YEAR-3, JAN, FEB, ..., DEC

 What I want is the mean(s) for just the consecutive winter months:
  YEAR-1.DEC, YEAR-2.JAN, YEAR-2.FEB
  YEAR-2.DEC, YEAR-3.JAN, YEAR-3.FEB
  etc.

 Thanks.

 __
 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.


[[alternative HTML version deleted]]

__
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-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] Expression: +/-sigma

2011-07-27 Thread ogbos okike
Dear List,
I am trying to label a plot with the symbol +/- sigma. Using something like
- expression (2*sigma) gives me the symbol 2ó. However, adding +/- to it
beats me.
The code I am using is:  plot(x,y,type=l,main= expression(paste(±,
plain(2*ó)),sep=).
Any suggestion will be appreciated.
Best
Ogbos

[[alternative HTML version deleted]]

__
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] Expression: +/-sigma

2011-07-27 Thread Yves REECHT
  Hi,

You may try something like:

plot(rnorm(10), rnorm(10), main=expression( %+-% 2*sigma))

HTH,
Yves

Le 27/07/2011 14:57, ogbos okike a écrit :
 Dear List,
 I am trying to label a plot with the symbol +/- sigma. Using something like
 - expression (2*sigma) gives me the symbol 2ó. However, adding +/- to it
 beats me.
 The code I am using is:  plot(x,y,type=l,main= expression(paste(±,
 plain(2*ó)),sep=).
 Any suggestion will be appreciated.
 Best
 Ogbos

   [[alternative HTML version deleted]]



 __
 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.

[[alternative HTML version deleted]]

__
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] Expression: +/-sigma

2011-07-27 Thread David Winsemius


On Jul 27, 2011, at 8:57 AM, ogbos okike wrote:


Dear List,
I am trying to label a plot with the symbol +/- sigma. Using  
something like
- expression (2*sigma) gives me the symbol 2ó. However, adding +/-  
to it

beats me.
The code I am using is:  plot(x,y,type=l,main=  
expression(paste(±,

plain(2*ó)),sep=).
Any suggestion will be appreciated.


1) If you are getting errors then you should post them.

2) There is no `sep =` argument in plotmath's paste function.

3) It is an error to put double quotes before the `expression`  
function call.


4) once those errors are corrected the ± is properly rendered in the  
title.



Best
Ogbos

[[alternative HTML version deleted]]

__
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] expression() and axis labels

2011-07-16 Thread Thomthom
Hi everyone!

I tried to look up in the previous topics whether there was something
similar to my question but I think there's nothing corresponding...

Anyway! Here is my problem:

I have a plot (qplot()) in which I want to insert axis labels with the
following text:

kg NH4+ N-equiv. * ha-1 yr-1 (well... 4 smaller and down and + as a power
(the same for the -1) but I am sure you understood what I meant).

So, in my code, I typed : 

qplot(, xlab=Amount of N-fertilizer expression(kg NH[4]^+ N-equiv. *
ha^-1 yr^-1))

but I don't get what I expect... everything after the first ^ is
considered as a power, whereas I would like to have only the + and the -1 as
a power.

Is there a way to obtain what I want? somehow to split up the expression so
I don't get everything put at the power of NH4.

I already thank you guys for your help!!!

Thomthom

--
View this message in context: 
http://r.789695.n4.nabble.com/expression-and-axis-labels-tp3672050p3672050.html
Sent from the R help mailing list archive at Nabble.com.

__
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] expression() and axis labels

2011-07-16 Thread David Winsemius


On Jul 16, 2011, at 12:09 PM, Thomthom wrote:


Hi everyone!

I tried to look up in the previous topics whether there was something
similar to my question but I think there's nothing corresponding...

Anyway! Here is my problem:

I have a plot (qplot()) in which I want to insert axis labels with the
following text:

kg NH4+ N-equiv. * ha-1 yr-1 (well... 4 smaller and down and + as a  
power

(the same for the -1) but I am sure you understood what I meant).

So, in my code, I typed :

qplot(, xlab=Amount of N-fertilizer expression(kg NH[4]^+ N- 
equiv. *

ha^-1 yr^-1))


I have never see a successful concatenation of regular text in quotes  
with expression(...), so my efforts were focussed on making a  
sytactically correct expression:


plot(1~1, xlab=expression(Amount~of~N-fertilizer~kg~NH[4]^+***N- 
equiv.~

ha^-1*yr^-1) )


You need to forget about spaces as separators since they are ignored,   
and use either ~ or * as connectives and that also means that if  
you want * to appear, it needs to be quoted.


plot(1~1, xlab=expression(Amount~of~N-fertilizer~kg~ NH[4]^ + *   
*  *  N-equiv.~
ha^-1 * yr^-1) )  # spaces added bak to show grouping, but they are  
still ignored.


I'm guessing you want the last part in parens:

plot(1~1, xlab=expression(Amount~of~N-fertilizer~kg~ NH[4]^ + *
   group((, list( N-equiv.~ ha^-1 * yr^-1),  
) ))


--
David



but I don't get what I expect... everything after the first ^ is
considered as a power, whereas I would like to have only the + and  
the -1 as

a power.

Is there a way to obtain what I want? somehow to split up the  
expression so

I don't get everything put at the power of NH4.

I already thank you guys for your help!!!

Thomthom

--
View this message in context: 
http://r.789695.n4.nabble.com/expression-and-axis-labels-tp3672050p3672050.html
Sent from the R help mailing list archive at Nabble.com.

__
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] expression() and axis labels

2011-07-16 Thread Joshua Wiley
On Sat, Jul 16, 2011 at 10:10 AM, David Winsemius
dwinsem...@comcast.net wrote:

 On Jul 16, 2011, at 12:09 PM, Thomthom wrote:

 Hi everyone!

 I tried to look up in the previous topics whether there was something
 similar to my question but I think there's nothing corresponding...

 Anyway! Here is my problem:

 I have a plot (qplot()) in which I want to insert axis labels with the
 following text:

 kg NH4+ N-equiv. * ha-1 yr-1 (well... 4 smaller and down and + as a power
 (the same for the -1) but I am sure you understood what I meant).

 So, in my code, I typed :

 qplot(, xlab=Amount of N-fertilizer expression(kg NH[4]^+ N-equiv. *
 ha^-1 yr^-1))

 I have never see a successful concatenation of regular text in quotes with
 expression(...), so my efforts were focussed on making a sytactically
 correct expression:

 plot(1~1, xlab=expression(Amount~of~N-fertilizer~kg~NH[4]^+***N-equiv.~
 ha^-1*yr^-1) )

Just a quick addition to David's excellent reply, if you have a lot of
contiguous text and find '~' cumbersome you can also put it all in
quotes:

xn - expression(Ammount of N-fertilizer kg
~NH[4]^+~~N-equiv.~*~ha^-1~yr^-1)
qplot(1:10, 1:10, xlab = xn)

Cheers,

Josh



 You need to forget about spaces as separators since they are ignored,  and
 use either ~ or * as connectives and that also means that if you want
 * to appear, it needs to be quoted.

 plot(1~1, xlab=expression(Amount~of~N-fertilizer~kg~ NH[4]^ + *  *  *
  N-equiv.~
 ha^-1 * yr^-1) )  # spaces added bak to show grouping, but they are still
 ignored.

 I'm guessing you want the last part in parens:

 plot(1~1, xlab=expression(Amount~of~N-fertilizer~kg~ NH[4]^ + *
                       group((, list( N-equiv.~ ha^-1 * yr^-1), ) ))

 --
 David


 but I don't get what I expect... everything after the first ^ is
 considered as a power, whereas I would like to have only the + and the -1
 as
 a power.

 Is there a way to obtain what I want? somehow to split up the expression
 so
 I don't get everything put at the power of NH4.

 I already thank you guys for your help!!!

 Thomthom

 --
 View this message in context:
 http://r.789695.n4.nabble.com/expression-and-axis-labels-tp3672050p3672050.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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.


-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
https://joshuawiley.com/

__
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] expression() and axis labels

2011-07-16 Thread Uwe Ligges



On 16.07.2011 19:10, David Winsemius wrote:


On Jul 16, 2011, at 12:09 PM, Thomthom wrote:


Hi everyone!

I tried to look up in the previous topics whether there was something
similar to my question but I think there's nothing corresponding...

Anyway! Here is my problem:

I have a plot (qplot()) in which I want to insert axis labels with the
following text:

kg NH4+ N-equiv. * ha-1 yr-1 (well... 4 smaller and down and + as a power
(the same for the -1) but I am sure you understood what I meant).

So, in my code, I typed :

qplot(, xlab=Amount of N-fertilizer expression(kg NH[4]^+
N-equiv. *
ha^-1 yr^-1))


I have never see a successful concatenation of regular text in quotes
with expression(...), so my efforts were focussed on making a
sytactically correct expression:

plot(1~1, xlab=expression(Amount~of~N-fertilizer~kg~NH[4]^+***N-equiv.~
ha^-1*yr^-1) )


You need to forget about spaces as separators since they are ignored,
and use either ~ or * as connectives and that also means that if you
want * to appear, it needs to be quoted.

plot(1~1, xlab=expression(Amount~of~N-fertilizer~kg~ NH[4]^ + * * *
N-equiv.~
ha^-1 * yr^-1) ) # spaces added bak to show grouping, but they are still
ignored.


You can use spaces if you just quote your text, of course:

plot(1~1, xlab = expression(Amount of N-fertilizer kg  * NH[4]^+ * 
* *  N-equiv.  * ha^-1 * yr^-1) )


Best,
Uwe




I'm guessing you want the last part in parens:

plot(1~1, xlab=expression(Amount~of~N-fertilizer~kg~ NH[4]^ + *
group((, list( N-equiv.~ ha^-1 * yr^-1), ) ))



__
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] expression() and axis labels

2011-07-16 Thread Thomthom
Thanks everyone!

This is exactly what I needed! My graphs look perfect now thanks to you
guys! :)

Thanks so much! I've spent hours on this...

Last question though: do I need to edit my post and signal it as a solved
topic (I saw that on other forums... and I have to admit I am not really
familiar with forums ^^)

Have a good one!

Thomthom


--
View this message in context: 
http://r.789695.n4.nabble.com/expression-and-axis-labels-tp3672050p3672221.html
Sent from the R help mailing list archive at Nabble.com.

__
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] expression() and axis labels

2011-07-16 Thread Uwe Ligges



On 16.07.2011 20:01, Thomthom wrote:

Thanks everyone!

This is exactly what I needed! My graphs look perfect now thanks to you
guys! :)

Thanks so much! I've spent hours on this...

Last question though: do I need to edit my post and signal it as a solved
topic (I saw that on other forums... and I have to admit I am not really
familiar with forums ^^)


Nor am I: This is not a forum but a mailing list! You probably accessed 
it via an interface that made it look like a forum.
In order to learn how to behave in an aoptimal fashion, just read the 
posting guide cited in the footer of each messages to the list.


Best,
Uwe Ligges




Have a good one!

Thomthom


--
View this message in context: 
http://r.789695.n4.nabble.com/expression-and-axis-labels-tp3672050p3672221.html
Sent from the R help mailing list archive at Nabble.com.

__
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-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] expression at labels in contour function

2011-03-10 Thread Rogerio Porto
Hello,

I'm stuck with the following code.

p - 0:100/100
a - 0:200/100
beta - matrix(a + p%x%(1-a), nrow=length(a), ncol=length(p))
lb - c(expression(beta==0), expression(beta==0.2), expression(beta==0.4),
expression(beta==0.6), expression(beta==0.8), expression(beta==1),
expression(beta==1.2), expression(beta==1.4), expression(beta==1.6),
expression(beta==1.8))
contour(a, p, beta, labcex=1, labels=lb)

Does anybody have an idea on how to make the greek letters appear
at the equi-\beta curves?

I'm running R version 2.11.1 on a 32-bit Windows 7 Starter and on a
Windows Vista Business without success.

Thanks in advance,

Rogerio

__
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] expression help

2011-03-01 Thread Daryl Morris

Hello,

I am trying to write math-type on a plot.  Due to space limitations on 
the plot, I want 2 short expressions written on top of each other.  It 
is certainly possible to write them in two separate calls, but that 
involves fine-tuning locations and a lot of trial and error (and I'm 
trying to write a general purpose function).


Here's where I've gotten to:
plot(0:1,0:1,xaxt=n)
axis(side=1,at=.3,expression(paste(IFN-, gamma, \n, TNF-, alpha)))
axis(side=1,at=.6,a label\n2nd line)

What I am trying to do is illustrated by the the non-expression axis 
label (a label\n2nd line).  The \n forces a new line when I'm not 
using expressions, but doesn't work for my real example.


I have googled for general documentation on expressions, but the only 
thing I've been able to find is the help for plotmath(), so if someone 
can point me to more complete documentation that would also be helpful.


thanks, Daryl
SCHARP, FHCRC, UW Biostatistics

__
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] expression help

2011-03-01 Thread Dennis Murphy
Hi:

1. expression() in plotmath ignores control characters such as \n.
2. The workaround, discussed a couple of times on this list (hence in the
archives), is to use the atop function, so try something like

plot(0:1,0:1,xaxt=n)
axis(side=1,at=.3,expression(paste(IFN-, gamma, \n, TNF-, alpha)))
axis(side=1,at=.6,expression(atop(a label, 2nd line)))

It appears you'll have to make some vertical adjustments, but that's the
basic workaround.

HTH,
Dennis

On Tue, Mar 1, 2011 at 11:32 AM, Daryl Morris dar...@uw.edu wrote:

 Hello,

 I am trying to write math-type on a plot.  Due to space limitations on the
 plot, I want 2 short expressions written on top of each other.  It is
 certainly possible to write them in two separate calls, but that involves
 fine-tuning locations and a lot of trial and error (and I'm trying to write
 a general purpose function).

 Here's where I've gotten to:
 plot(0:1,0:1,xaxt=n)
 axis(side=1,at=.3,expression(paste(IFN-, gamma, \n, TNF-, alpha)))
 axis(side=1,at=.6,a label\n2nd line)

 What I am trying to do is illustrated by the the non-expression axis label
 (a label\n2nd line).  The \n forces a new line when I'm not using
 expressions, but doesn't work for my real example.

 I have googled for general documentation on expressions, but the only thing
 I've been able to find is the help for plotmath(), so if someone can point
 me to more complete documentation that would also be helpful.

 thanks, Daryl
 SCHARP, FHCRC, UW Biostatistics

 __
 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.


[[alternative HTML version deleted]]

__
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] expression for index of pairwise combinations

2011-02-09 Thread Pete Brecknock

If I have understood correctly, then as an example for 4 columns how about


d=data.frame(C1=c(1,1,1,1,1),C2=c(2,2,2,2,2),C3=c(3,3,3,3,3),C4=c(4,4,4,4,4))

combs=combn(paste(C,seq_len(4),sep=),2,simplify=FALSE)

one =  sapply(combs,function(x) d[x[1]])
two =  sapply(combs,function(x) d[x[2]])

ret = mapply(cbind,one,two)
colnames(ret) = paste(C,1:length(combs),sep=)

You will need to change seq_len(4) to seq_len(269) in the second line.

HTH

Pete
-- 
View this message in context: 
http://r.789695.n4.nabble.com/expression-for-index-of-pairwise-combinations-tp3263025p3298495.html
Sent from the R help mailing list archive at Nabble.com.

__
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] expression() problem !

2010-10-11 Thread michel.mas

Hello everyone ... I have a problem when I try to mix expressions using the
function expression () with variables coming from my code. Has anyone faced
such a problem?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/expression-problem-tp2990891p2990891.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
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] expression() problem !

2010-10-11 Thread David Winsemius


On Oct 11, 2010, at 7:27 PM, michel.mas wrote:



Hello everyone ... I have a problem when I try to mix expressions  
using the
function expression () with variables coming from my code. Has  
anyone faced

such a problem?


Many times:

?bquote   # instead of expression



--
View this message in context: 
http://r.789695.n4.nabble.com/expression-problem-tp2990891p2990891.html
Sent from the R help mailing list archive at Nabble.com.

--

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] expression() and plot title

2010-08-28 Thread Cheng Peng

Try this:

 LinePlot(1,1)
 LinePlot=function(a,b){
+ # a = slope
+ # b = y intercept
+ x=seq(-10,10,0.4)
+ y=a*x+b
+ plot(x,y, type=l)
+ title(paste(a=,a,b=,b))
+ }
 
 #test
 LinePlot(a=-2,b=9)

HTH


-- 
View this message in context: 
http://r.789695.n4.nabble.com/expression-and-plot-title-tp2348566p2350361.html
Sent from the R help mailing list archive at Nabble.com.

__
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] expression() and plot title

2010-08-28 Thread Sancar Adali
My function is like this
sim.res-gaussian_simulation(p=3, r=4, q=3, c=0.1,d=2,
Wchoice = avg,
pre.scaling = TRUE,
oos = TRUE,
alpha   = NULL,
n = 100, m = 100, nmc = 100)

which is defined as
gaussian_simulation - function(p, r, q, c,
 d   = p-1,
 pprime1 = p+q,   # cca arguments
 pprime2 = p+q,   # cca arguments
 Wchoice = avg,
 pre.scaling = TRUE,
 oos = TRUE,
 alpha   = NULL,
 n = 100, m = 100, nmc = 100)
and I want to title the plot after I invoke the gaussian_simulation function
sim.res-gaussian_simulation(p=3, r=4, q=3, c=0.1,d=2,
Wchoice = avg,
pre.scaling = TRUE,
oos = TRUE,
alpha   = NULL,
n = 100, m = 100, nmc = 100)
plot(sim.res)
title(p=3, r=4, q=3, c=0.1,d=2)

On Sat, Aug 28, 2010 at 12:53 AM, Sancar Adali sad...@gmail.com wrote:

 What I want to do is put the arguments I supply to a function  into the
 title of a plot
 Say I'm calling func.1
 func.1(a=4,b=4)
 plot(,..., title(a=4, b=4))
 If I'm calling func.1 with different arguments, I want the plot title to
 reflect that.
 A small detail is that func.1 might have an argument with a default like
  c=a+b. I tried using expression but couldn't get it to work.

 Is there a way to do this using expression() ?

 --
 Sancar Adali




-- 
Sancar Adali
Johns Hopkins University
Graduate Student

[[alternative HTML version deleted]]

__
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] expression() and plot title

2010-08-28 Thread David Winsemius


On Aug 28, 2010, at 4:48 PM, Sancar Adali wrote:


My function is like this
sim.res-gaussian_simulation(p=3, r=4, q=3, c=0.1,d=2,
Wchoice = avg,
pre.scaling = TRUE,
oos = TRUE,
alpha   = NULL,
n = 100, m = 100, nmc = 100)

which is defined as
gaussian_simulation - function(p, r, q, c,
d   = p-1,
pprime1 = p+q,   # cca arguments
pprime2 = p+q,   # cca arguments
Wchoice = avg,
pre.scaling = TRUE,
oos = TRUE,
alpha   = NULL,
n = 100, m = 100, nmc = 100)


Not much of a definition...no body???

and I want to title the plot after I invoke the gaussian_simulation  
function

sim.res-gaussian_simulation(p=3, r=4, q=3, c=0.1,d=2,
Wchoice = avg,
pre.scaling = TRUE,
oos = TRUE,
alpha   = NULL,
n = 100, m = 100, nmc = 100)
plot(sim.res)
title(p=3, r=4, q=3, c=0.1,d=2)


The following assumes you want the values of those parameters for the  
title to be picked up from the function's arguments, because the code  
you offer for the title is syntactically correct. You first need to re- 
read Bill Venables response regarding bquote which you show no signs  
of adapting,  and then you need to study:


?plotmath

... where you will learn the proper syntax for =  (==) and for  
comma-separated lists. You should not need the quotes inside the  
bquote call. The ~ (space) and * (no space) are syntactic  
separators inside expressions (in the limited scope of the plotmath  
perspective). The plotmath interpretation of these is not well  
described in the documentation (IMO). The help page could easily lead  
you to think that commas or spaces might be valid separators, or that  
list() was the same as list() in regular R, and it's only by repeated  
errors and reading worked examples on r-help that I have learned  
otherwise.


Consider this and apply lessons learned:

plot(1,1); p=3; r=4; q=3; c=0.1; d=2
title(main= bquote( list(p==.(p), r==.(r), q==.(q), c==.(c), d==. 
(d)) ) )


# you might get away with not using the main argument name, but I  
think it's bad practice.


--
David.


On Sat, Aug 28, 2010 at 12:53 AM, Sancar Adali sad...@gmail.com  
wrote:


What I want to do is put the arguments I supply to a function  into  
the

title of a plot
Say I'm calling func.1
func.1(a=4,b=4)
plot(,..., title(a=4, b=4))
If I'm calling func.1 with different arguments, I want the plot  
title to

reflect that.
A small detail is that func.1 might have an argument with a default  
like

c=a+b. I tried using expression but couldn't get it to work.

Is there a way to do this using expression() ?

--
Sancar Adali



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] expression() and plot title

2010-08-27 Thread Sancar Adali
What I want to do is put the arguments I supply to a function  into the
title of a plot
Say I'm calling func.1
func.1(a=4,b=4)
plot(,..., title(a=4, b=4))
If I'm calling func.1 with different arguments, I want the plot title to
reflect that.
A small detail is that func.1 might have an argument with a default like
 c=a+b. I tried using expression but couldn't get it to work.

Is there a way to do this using expression() ?

-- 
Sancar Adali

[[alternative HTML version deleted]]

__
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] expression() and plot title

2010-08-27 Thread David Winsemius


On Aug 28, 2010, at 12:53 AM, Sancar Adali wrote:

What I want to do is put the arguments I supply to a function  into  
the

title of a plot
Say I'm calling func.1
func.1(a=4,b=4)
plot(,..., title(a=4, b=4))


If I'm calling func.1 with different arguments, I want the plot  
title to

reflect that.
A small detail is that func.1 might have an argument with a default  
like

c=a+b.


 Need a code example.


I tried using expression but couldn't get it to work.


You should be using bquote.



Is there a way to do this using expression() ?


Refer to the answers given earlier today. Subject line:
How to plot an expression-label with variable text

--
David.

__
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] expression() and plot title

2010-08-27 Thread Bill.Venables
Here is a suggestion you may care to develop

func - function(a, b) {
plot(1:10)
title(main = bquote(a == .(a)*','~ b == .(b)))
invisible()
}

try with

func(1,2)
func(36, 2^10) 
c

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Sancar Adali
Sent: Saturday, 28 August 2010 2:54 PM
To: r-help
Subject: [R] expression() and plot title

What I want to do is put the arguments I supply to a function  into the
title of a plot
Say I'm calling func.1
func.1(a=4,b=4)
plot(,..., title(a=4, b=4))
If I'm calling func.1 with different arguments, I want the plot title to
reflect that.
A small detail is that func.1 might have an argument with a default like
 c=a+b. I tried using expression but couldn't get it to work.

Is there a way to do this using expression() ?

-- 
Sancar Adali

[[alternative HTML version deleted]]

__
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-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] expression over-plotted

2010-03-26 Thread Brad Eck

   When I try to add the following annotation to a plot the entries are plotted
   one on top of the other.  I'm trying to get something that looks like  eta
   =  0.2where the Greek letter is used on the plot.  I realize that
   expression( eta == 0.2) is one solution, but ultimately I'd like to use this
   in a legend that uses a loop to fill the entries so I don't want the 0.2
   entered manually.
   val - 0.2
   plot( c(0,1), c(0,1) )
   text(  0.5, 0.5, c( expression( eta ), paste( ' = ', val ) ) )
   Thanks,
   Brad
__
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] expression over-plotted

2010-03-26 Thread Chris Campbell
On Fri, Mar 26, 2010 at 16:05, Brad Eck brad@mail.utexas.edu wrote:

   When I try to add the following annotation to a plot the entries are plotted
   one on top of the other.  I'm trying to get something that looks like  eta
   =  0.2    where the Greek letter is used on the plot.  I realize that
   expression( eta == 0.2) is one solution, but ultimately I'd like to use this
   in a legend that uses a loop to fill the entries so I don't want the 0.2
   entered manually.
   val - 0.2
   plot( c(0,1), c(0,1) )
   text(  0.5, 0.5, c( expression( eta ), paste( ' = ', val ) ) )
   Thanks,
   Brad
 __
 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.



Your text is a vector of length 2 and you are plotting each element
over the same x,y coordinates, hence the overlap.  You could either
add a second x-coordinate to spread things out:

text(  c(0.5,0.55), 0.5, c( expression( eta ), paste( ' = ', val ) ) )

or use bquote:

text(  0.5, 0.5, bquote(eta == .(val) ) )

Hope that helps

__
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] expression(), mixed symbols and evaluated objects

2010-03-10 Thread Markus Loecher
Is it possible to mix symbols and evaluated objects inside the expression()
function ?
The following example shows what I am trying to achieve:

for (m in 1:3) {
plot(1:10); #just a place holder for the real plots
title(expression(y = m * lambda));
}

I want to actually evaluate the variable m but keep lambda as a symbol in
the title.
I tried to wrap an eval() around various subparts of the expression but to
no avail.

Going further, I ideally would like to mix text into the expression as well.

Any help would be appreciated.

Thanks,

Markus

[[alternative HTML version deleted]]

__
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] expression(), mixed symbols and evaluated objects

2010-03-10 Thread Duncan Murdoch

On 10/03/2010 8:52 AM, Markus Loecher wrote:

Is it possible to mix symbols and evaluated objects inside the expression()
function ?
The following example shows what I am trying to achieve:

for (m in 1:3) {
plot(1:10); #just a place holder for the real plots
title(expression(y = m * lambda));
}

I want to actually evaluate the variable m but keep lambda as a symbol in
the title.
I tried to wrap an eval() around various subparts of the expression but to
no avail.

Going further, I ideally would like to mix text into the expression as well.

Any help would be appreciated.
Use bquote.  It returns an expression after evaluating only the parts 
wrapped in .().  For example,


for (m in 1:3) {
   plot(1:10); #just a place holder for the real plots
   title(bquote(y == .(m) * lambda));
}

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.


[R] expression() help

2010-02-12 Thread Peng Cai
Hi All,

I'm trying to use expression() for y-label in plot(). I'm not able to write
Average(space)PM(subscript)10. I'm trying:

ylab=expression(Average PM[10])

and its not working, because of a space between Average and PM. Thanks,
Peng

[[alternative HTML version deleted]]

__
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] expression() help

2010-02-12 Thread Henrique Dallazuanna
Try this:

expression(Average~PM[10])

On Fri, Feb 12, 2010 at 3:29 PM, Peng Cai pengcaimaill...@gmail.com wrote:
 Hi All,

 I'm trying to use expression() for y-label in plot(). I'm not able to write
 Average(space)PM(subscript)10. I'm trying:

 ylab=expression(Average PM[10])

 and its not working, because of a space between Average and PM. Thanks,
 Peng

        [[alternative HTML version deleted]]

 __
 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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] expression() help

2010-02-12 Thread Thomas Lumley

On Fri, 12 Feb 2010, Peng Cai wrote:


Hi All,

I'm trying to use expression() for y-label in plot(). I'm not able to write
Average(space)PM(subscript)10. I'm trying:

ylab=expression(Average PM[10])

and its not working, because of a space between Average and PM. Thanks,


quote(Average PM[10]) or quote(Average~PM[10]) seem to work.  There is an 
example of the first style in ?plotmath.

 -thomas


Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
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] expression()

2009-12-20 Thread Kim Jung Hwa
Hi All,

I'm wondering if its possible to write degree in symbol.

I would like y-label as Temperature (degreeF). where degree should be in
symbols. Thanks in advance,

#R Code
library(lattice)
data(barley)
barchart(yield ~ variety | site, data = barley,
 groups = year, layout = c(1,6),
 ylab = Temperature (degreeF),
 scales = list(x = list(abbreviate = TRUE,
   minlength = 5)))
~Kim Jung Hwa

[[alternative HTML version deleted]]

__
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] expression()

2009-12-20 Thread baptiste auguie
Hi,

try this,

ylab = expression(Temperature~(degree*F))

?plotmath

baptiste

2009/12/20 Kim Jung Hwa kimhwamaill...@gmail.com:
 Hi All,

 I'm wondering if its possible to write degree in symbol.

 I would like y-label as Temperature (degreeF). where degree should be in
 symbols. Thanks in advance,

 #R Code
 library(lattice)
 data(barley)
 barchart(yield ~ variety | site, data = barley,
         groups = year, layout = c(1,6),
         ylab = Temperature (degreeF),
         scales = list(x = list(abbreviate = TRUE,
                       minlength = 5)))
 ~Kim Jung Hwa

        [[alternative HTML version deleted]]

 __
 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-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] expression and font type of bold

2009-12-04 Thread Alla Bulashevska
Dear R users,
i would like to have expression on my plot written in bold
italic font and use following:
text(0.01,70,expression(bolditalic(r^2==0.67)),pos= 4)
However, only the letter r appears bold and italic, but not
the whole expression. How should i change it?

Thank you for your help,
Alla.

__
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] expression

2009-09-16 Thread Marco Chiapello

/Dear all,///
/I am very thankful, if you could tell what is the right way to write:

mtext(paste(expression(R^2),round(marco2[1,i],digits=3),   N° of 
proteins:,marco3[i]),side=4,cex=.6)

in this case the output is:

R^2

I tried also in this way:

mtext(paste(expression(paste(R^2)),round(marco2[1,i],digits=3),   N° of 
proteins:,marco3[i]),side=4,cex=.6)

the output is:

paste(R^2)

Thank you in advance
Marco
/

__
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] expression

2009-09-16 Thread baptiste auguie
Try this,

marco2 = matrix(rnorm(4), nrow=2, ncol=2)
marco3 = 2.12
i =1

plot.new()
mtext(bquote(R^2*.(round(marco2[1,i],digits=3))* N° of
proteins:*.(marco3[i])),side=4,cex=.6)


HTH,

baptiste

2009/9/16 Marco Chiapello marpe...@gmail.com

 /Dear all,///
 /I am very thankful, if you could tell what is the right way to write:

 mtext(paste(expression(R^2),round(marco2[1,i],digits=3),   N° of
 proteins:,marco3[i]),side=4,cex=.6)

 in this case the output is:

 R^2

 I tried also in this way:

 mtext(paste(expression(paste(R^2)),round(marco2[1,i],digits=3),   N° of
 proteins:,marco3[i]),side=4,cex=.6)

 the output is:

 paste(R^2)

 Thank you in advance
 Marco
 /

 __
 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.




-- 
_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

http://newton.ex.ac.uk/research/emag
__

[[alternative HTML version deleted]]

__
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] expression(paste with the superscript in bold font

2009-05-08 Thread Arnaldo Russo
Hi,

I`m trying to put my superscript type in bold style. Could somebody help me?

My text is inside a barplot.

#!/bin/Rbarplot(x, ylab=expression(paste(org., cm^-2)))

# so I tried this way,

*barplot(x, ylab=expression(bold(paste(org., cm^-2* # but my
superscript maintain its shape in regular font type.

Thank you all.

[[alternative HTML version deleted]]

__
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] Expression in axis

2008-07-09 Thread Dani Valverde

Hello,
I am creating a plot and I would like to know how to put this expression 
to the y axis

   µmol/10^6 cells
I've tried some combinations using the expression() function, but none 
of them worked.

Any idea?

Best,

Dani

--
Daniel Valverde Saubí

Grup de Biologia Molecular de Llevats
Facultat de Veterinària de la Universitat Autònoma de Barcelona
Edifici V, Campus UAB
08193 Cerdanyola del Vallès- SPAIN

Centro de Investigación Biomédica en Red
en Bioingeniería, Biomateriales y
Nanomedicina (CIBER-BBN)

Grup d'Aplicacions Biomèdiques de la RMN
Facultat de Biociències
Universitat Autònoma de Barcelona
Edifici Cs, Campus UAB
08193 Cerdanyola del Vallès- SPAIN
+34 93 5814126

__
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] Expression in axis

2008-07-09 Thread Daniel Malter
x=rnorm(100,0,10)
y=rnorm(100,0,10)
plot(y~x,xlab=µmol/10^6)

Is that it?

Best,
Daniel 


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
Auftrag von Dani Valverde
Gesendet: Wednesday, July 09, 2008 5:22 AM
An: R Help
Betreff: [R] Expression in axis

Hello,
I am creating a plot and I would like to know how to put this expression to
the y axis
µmol/10^6 cells I've tried
some combinations using the expression() function, but none of them worked.
Any idea?

Best,

Dani

--
Daniel Valverde Saubí

Grup de Biologia Molecular de Llevats
Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V,
Campus UAB
08193 Cerdanyola del Vallès- SPAIN

Centro de Investigación Biomédica en Red en Bioingeniería, Biomateriales y
Nanomedicina (CIBER-BBN)

Grup d'Aplicacions Biomèdiques de la RMN Facultat de Biociències Universitat
Autònoma de Barcelona Edifici Cs, Campus UAB
08193 Cerdanyola del Vallès- SPAIN
+34 93 5814126

__
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-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] Expression in axis

2008-07-09 Thread Gabor Csardi
E.g.

 plot(1:10,1:10,xlab=NA)
 title(xlab=expression(mu*mol/10^6* cells))

Gabor

On Wed, Jul 09, 2008 at 11:21:46AM +0200, Dani Valverde wrote:
 Hello,
 I am creating a plot and I would like to know how to put this expression  
 to the y axis
µmol/10^6 cells
 I've tried some combinations using the expression() function, but none  
 of them worked.
 Any idea?

 Best,

 Dani

 -- 
 Daniel Valverde Saubí

 Grup de Biologia Molecular de Llevats
 Facultat de Veterinària de la Universitat Autònoma de Barcelona
 Edifici V, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN

 Centro de Investigación Biomédica en Red
 en Bioingeniería, Biomateriales y
 Nanomedicina (CIBER-BBN)

 Grup d'Aplicacions Biomèdiques de la RMN
 Facultat de Biociències
 Universitat Autònoma de Barcelona
 Edifici Cs, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN
 +34 93 5814126

 __
 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.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
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] Expression in axis

2008-07-09 Thread Daniel Malter

Sorry, you want it in the y-axis. So put ylab instead of xlab. Generally,
type ?plot in the R-prompt and hit enter. Click the little par link in the
middle of the page. There you see all the options (or at least very many)
that you can pass to your plot command.

Best,
Da.




Daniel Malter wrote:
 
 x=rnorm(100,0,10)
 y=rnorm(100,0,10)
 plot(y~x,xlab=µmol/10^6)
 
 Is that it?
 
 Best,
 Daniel 
 
 
 -
 cuncta stricte discussurus
 -
 
 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
 Auftrag von Dani Valverde
 Gesendet: Wednesday, July 09, 2008 5:22 AM
 An: R Help
 Betreff: [R] Expression in axis
 
 Hello,
 I am creating a plot and I would like to know how to put this expression
 to
 the y axis
 µmol/10^6 cells I've tried
 some combinations using the expression() function, but none of them
 worked.
 Any idea?
 
 Best,
 
 Dani
 
 --
 Daniel Valverde Saubí
 
 Grup de Biologia Molecular de Llevats
 Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V,
 Campus UAB
 08193 Cerdanyola del Vallès- SPAIN
 
 Centro de Investigación Biomédica en Red en Bioingeniería, Biomateriales y
 Nanomedicina (CIBER-BBN)
 
 Grup d'Aplicacions Biomèdiques de la RMN Facultat de Biociències
 Universitat
 Autònoma de Barcelona Edifici Cs, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN
 +34 93 5814126
 
 __
 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-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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Expression-in-axis-tp18357570p18357802.html
Sent from the R help mailing list archive at Nabble.com.

__
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] expression, strsplit, ...

2008-06-26 Thread baptiste Auguié


On 25 Jun 2008, at 19:45, Gabor Grothendieck wrote:


Try this:

plot(1, xlab = ~ alpha / V * m^-3 * kg ^-2 * l^4)




Thanks, I would never have expected this code to work, this is a  
mystery to me! Actually, I thought xlab wanted an expression, but it  
seems to be happy with a formula. Also, the handling of exponents is  
cleverer than I naively assumed. I think an example like the one  
above would make a nice addition to the plotmath documentation.


One small thing bothers me: can one use a similar syntax and use  
something like bquote to substitute a variable?


say,

a -  some text 


plot(1, xlab = ~ alpha *  `a` / V * m^-3 * kg ^-2 * l^4)


to produce,



plot(1, xlab = ~ alpha *  some text  / V * m^-3 * kg ^-2 * l^4)


but I can't get either bquote, deparse, substitute, `` to produce  
the desired substitution in this formula.


Many thanks,

baptiste






On Wed, Jun 25, 2008 at 1:06 PM, baptiste Auguié  
[EMAIL PROTECTED] wrote:

DeaR list,

I'm a bit lost in the behavior of substitute and co.
I often use fairly long axis labels in my graphs (long to write,  
that is).
Typically, they would contain some greek letters and units with  
exponents,

as in:

   xlab=expression(paste(text , alpha,  / , V,., m^ 
{-3}, .,

kg^{-2}, ., l^{4}))



To make this a bit prettier, I've attempted to mimic the behavior  
of the

SIstyle latex package which defines a macro that cleverly parses an
expression for units, exponents, etc. My code fails in putting  
together the

unit, as seen in the example below:



makeUnits - function(expr){ # formats the units

units.list - strsplit(expr, [[:blank:]], perl=F)
expr.list - strsplit(unlist(units.list), \\^, perl=T)

units - unlist(lapply(expr.list, function(unit) {
   if (length(unit) == 2)
paste(unit[1],^{,unit[2],},sep=)
   else paste(unit,sep=)
   }))
   cat(units, sep=.)
}

expr - V m^-3 kg^-2 l^4
makeUnits(expr) # this works, and produces:


# V.m^{-3}.kg^{-2}.l^{4}


silab - function(..., units=NULL){ # creates a valid expression  
for xlab

and co.
   dotCalls - substitute(list(...))
   nArgs - length(dotCalls)
if (!is.null(units))myUnits - makeUnits(units)
if (!is.null(units)) return(substitute(paste(...,  / ,  myUnits)))
if (is.null(units)) return(substitute(paste(...)))
}

silab(text, alpha,  units = V m^-3 kg^-2 l^4) # the result is
obviously not what I want

par(mfrow=c(2, 1)) # comparison of the desired output and the  
current one

plot(1:10, 1:10,
   xlab=silab(text , alpha, units = V m^-3 kg^-2 l^4),
   ylab=silab(simple text))

plot(1:10, 1:10,
   xlab=expression(paste(text , alpha,  / , V,., m^ 
{-3}, .,

kg^{-2}, ., l^{4})),
   ylab=simple text)





Any thoughts welcome!

Sincerely,

baptiste

_

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto

__
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.



_

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto

__
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] expression, strsplit, ...

2008-06-26 Thread Gabor Grothendieck
bquote is used like this:

alpha - 5
xlab - bquote(.(alpha) / V * m^-3 * kg ^-2 * l^4)
plot(1, xlab = xlab)


On Thu, Jun 26, 2008 at 4:21 AM, baptiste Auguié [EMAIL PROTECTED] wrote:

 On 25 Jun 2008, at 19:45, Gabor Grothendieck wrote:

 Try this:

 plot(1, xlab = ~ alpha / V * m^-3 * kg ^-2 * l^4)



 Thanks, I would never have expected this code to work, this is a mystery to
 me! Actually, I thought xlab wanted an expression, but it seems to be happy
 with a formula. Also, the handling of exponents is cleverer than I naively
 assumed. I think an example like the one above would make a nice addition to
 the plotmath documentation.

 One small thing bothers me: can one use a similar syntax and use something
 like bquote to substitute a variable?

 say,

 a -  some text 

 plot(1, xlab = ~ alpha *  `a` / V * m^-3 * kg ^-2 * l^4)

 to produce,


 plot(1, xlab = ~ alpha *  some text  / V * m^-3 * kg ^-2 * l^4)

 but I can't get either bquote, deparse, substitute, `` to produce the
 desired substitution in this formula.

 Many thanks,

 baptiste





 On Wed, Jun 25, 2008 at 1:06 PM, baptiste Auguié [EMAIL PROTECTED]
 wrote:

 DeaR list,

 I'm a bit lost in the behavior of substitute and co.
 I often use fairly long axis labels in my graphs (long to write, that
 is).
 Typically, they would contain some greek letters and units with
 exponents,
 as in:

   xlab=expression(paste(text , alpha,  / , V,., m^{-3}, .,
 kg^{-2}, ., l^{4}))


 To make this a bit prettier, I've attempted to mimic the behavior of the
 SIstyle latex package which defines a macro that cleverly parses an
 expression for units, exponents, etc. My code fails in putting together
 the
 unit, as seen in the example below:


 makeUnits - function(expr){ # formats the units

 units.list - strsplit(expr, [[:blank:]], perl=F)
 expr.list - strsplit(unlist(units.list), \\^, perl=T)

 units - unlist(lapply(expr.list, function(unit) {
   if (length(unit) == 2)
 paste(unit[1],^{,unit[2],},sep=)
   else paste(unit,sep=)
   }))
   cat(units, sep=.)
 }

 expr - V m^-3 kg^-2 l^4
 makeUnits(expr) # this works, and produces:

 # V.m^{-3}.kg^{-2}.l^{4}

 silab - function(..., units=NULL){ # creates a valid expression for
 xlab
 and co.
   dotCalls - substitute(list(...))
   nArgs - length(dotCalls)
 if (!is.null(units))myUnits - makeUnits(units)
 if (!is.null(units)) return(substitute(paste(...,  / ,  myUnits)))
 if (is.null(units)) return(substitute(paste(...)))
 }

 silab(text, alpha,  units = V m^-3 kg^-2 l^4) # the result is
 obviously not what I want

 par(mfrow=c(2, 1)) # comparison of the desired output and the current
 one
 plot(1:10, 1:10,
   xlab=silab(text , alpha, units = V m^-3 kg^-2 l^4),
   ylab=silab(simple text))

 plot(1:10, 1:10,
   xlab=expression(paste(text , alpha,  / , V,., m^{-3}, .,
 kg^{-2}, ., l^{4})),
   ylab=simple text)




 Any thoughts welcome!

 Sincerely,

 baptiste

 _

 Baptiste Auguié

 Physics Department
 University of Exeter
 Stocker Road,
 Exeter, Devon,
 EX4 4QL, UK

 Phone: +44 1392 264187

 http://newton.ex.ac.uk/research/emag
 http://projects.ex.ac.uk/atto

 __
 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.


 _

 Baptiste Auguié

 Physics Department
 University of Exeter
 Stocker Road,
 Exeter, Devon,
 EX4 4QL, UK

 Phone: +44 1392 264187

 http://newton.ex.ac.uk/research/emag
 http://projects.ex.ac.uk/atto
 __







__
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] expression, strsplit, ...

2008-06-26 Thread Prof Brian Ripley

On Thu, 26 Jun 2008, baptiste Auguié wrote:



On 25 Jun 2008, at 19:45, Gabor Grothendieck wrote:


Try this:

plot(1, xlab = ~ alpha / V * m^-3 * kg ^-2 * l^4)




Thanks, I would never have expected this code to work, this is a mystery to 
me! Actually, I thought xlab wanted an expression, but it seems to be happy 
with a formula.



From ?plotmath


 In most cases other language objects (names and calls) are coerced
 to expressions and so can also be used.

A formula is a call:


mode(~ alpha / V * m^-3 * kg ^-2 * l^4)

[1] call

That was just GG saving himself a few key strokes at the expense of 
clarity:


plot(1, xlab = expression(alpha / V * m^-3 * kg ^-2 * l^4))

is what this is coerced to.



Also, the handling of exponents is cleverer than I naively assumed.


It is exactly as documented.

I think an example like the one above would make a nice addition to 
the plotmath documentation.


I don't see what it adds to those already there.



One small thing bothers me: can one use a similar syntax and use something 
like bquote to substitute a variable?


You use substitute() to do that:


substitute(alpha *  aaa / V * m^-3 * kg ^-2 * l^4, list(aaa=a))

alpha *  some text /V * m^-3 * kg^-2 * l^4


say,

a -  some text 


plot(1, xlab = ~ alpha *  `a` / V * m^-3 * kg ^-2 * l^4)


to produce,



plot(1, xlab = ~ alpha *  some text  / V * m^-3 * kg ^-2 * l^4)


but I can't get either bquote, deparse, substitute, `` to produce the 
desired substitution in this formula.


You can't 'substitute' in a formula, but you can in the RHS of a formula, 
form[[2]] in your case.



Many thanks,

baptiste






On Wed, Jun 25, 2008 at 1:06 PM, baptiste Auguié [EMAIL PROTECTED] 
wrote:

DeaR list,

I'm a bit lost in the behavior of substitute and co.
I often use fairly long axis labels in my graphs (long to write, that is).
Typically, they would contain some greek letters and units with exponents,
as in:


  xlab=expression(paste(text , alpha,  / , V,., m^{-3}, .,
kg^{-2}, ., l^{4}))



To make this a bit prettier, I've attempted to mimic the behavior of the
SIstyle latex package which defines a macro that cleverly parses an
expression for units, exponents, etc. My code fails in putting together 
the

unit, as seen in the example below:



makeUnits - function(expr){ # formats the units

units.list - strsplit(expr, [[:blank:]], perl=F)
expr.list - strsplit(unlist(units.list), \\^, perl=T)

units - unlist(lapply(expr.list, function(unit) {
  if (length(unit) == 2)
paste(unit[1],^{,unit[2],},sep=)
  else paste(unit,sep=)
  }))
  cat(units, sep=.)
}

expr - V m^-3 kg^-2 l^4
makeUnits(expr) # this works, and produces:


# V.m^{-3}.kg^{-2}.l^{4}


silab - function(..., units=NULL){ # creates a valid expression for xlab
and co.
  dotCalls - substitute(list(...))
  nArgs - length(dotCalls)
if (!is.null(units))myUnits - makeUnits(units)
if (!is.null(units)) return(substitute(paste(...,  / ,  myUnits)))
if (is.null(units)) return(substitute(paste(...)))
}

silab(text, alpha,  units = V m^-3 kg^-2 l^4) # the result is
obviously not what I want

par(mfrow=c(2, 1)) # comparison of the desired output and the current one
plot(1:10, 1:10,
  xlab=silab(text , alpha, units = V m^-3 kg^-2 l^4),
  ylab=silab(simple text))

plot(1:10, 1:10,
  xlab=expression(paste(text , alpha,  / , V,., m^{-3}, .,
kg^{-2}, ., l^{4})),
  ylab=simple text)





Any thoughts welcome!

Sincerely,

baptiste

_

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto

__
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.



_

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto

__
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.


--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
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

Re: [R] expression, strsplit, ...

2008-06-26 Thread baptiste Auguié
OK, thanks to both of you for the clarifications. I guess part of my  
confusion came from the numerous functions and concepts involved in  
producing such labels:


- call vs string vs formula vs expression ...

- substitute, bquote, expression, ~, .(), ...

I take it as a good thing once you have some experience, as it  
probably gives several ways to cat a string. The expense of clarity  
in the use of ~ was useful for me complaining about the rather  
verbose syntax of some plotmath examples. I may try to produce some  
examples in the future for the R wiki to illustrate these particular  
annotation details.


Thanks again,

Baptiste



On 26 Jun 2008, at 12:07, Prof Brian Ripley wrote:


On Thu, 26 Jun 2008, baptiste Auguié wrote:



On 25 Jun 2008, at 19:45, Gabor Grothendieck wrote:


Try this:
plot(1, xlab = ~ alpha / V * m^-3 * kg ^-2 * l^4)



Thanks, I would never have expected this code to work, this is a  
mystery to me! Actually, I thought xlab wanted an expression, but  
it seems to be happy with a formula.


From ?plotmath

 In most cases other language objects (names and calls) are  
coerced

 to expressions and so can also be used.

A formula is a call:


mode(~ alpha / V * m^-3 * kg ^-2 * l^4)

[1] call

That was just GG saving himself a few key strokes at the expense of  
clarity:


plot(1, xlab = expression(alpha / V * m^-3 * kg ^-2 * l^4))

is what this is coerced to.



Also, the handling of exponents is cleverer than I naively assumed.


It is exactly as documented.

I think an example like the one above would make a nice addition  
to the plotmath documentation.


I don't see what it adds to those already there.



One small thing bothers me: can one use a similar syntax and use  
something like bquote to substitute a variable?


You use substitute() to do that:


substitute(alpha *  aaa / V * m^-3 * kg ^-2 * l^4, list(aaa=a))

alpha *  some text /V * m^-3 * kg^-2 * l^4


say,

a -  some text 


plot(1, xlab = ~ alpha *  `a` / V * m^-3 * kg ^-2 * l^4)


to produce,



plot(1, xlab = ~ alpha *  some text  / V * m^-3 * kg ^-2 * l^4)


but I can't get either bquote, deparse, substitute, `` to  
produce the desired substitution in this formula.


You can't 'substitute' in a formula, but you can in the RHS of a  
formula, form[[2]] in your case.



Many thanks,

baptiste




On Wed, Jun 25, 2008 at 1:06 PM, baptiste Auguié  
[EMAIL PROTECTED] wrote:

DeaR list,
I'm a bit lost in the behavior of substitute and co.
I often use fairly long axis labels in my graphs (long to write,  
that is).
Typically, they would contain some greek letters and units with  
exponents,

as in:

  xlab=expression(paste(text , alpha,  / , V,., m^ 
{-3}, .,

kg^{-2}, ., l^{4}))
To make this a bit prettier, I've attempted to mimic the  
behavior of the

SIstyle latex package which defines a macro that cleverly parses an
expression for units, exponents, etc. My code fails in putting  
together the

unit, as seen in the example below:

makeUnits - function(expr){ # formats the units
units.list - strsplit(expr, [[:blank:]], perl=F)
expr.list - strsplit(unlist(units.list), \\^, perl=T)
units - unlist(lapply(expr.list, function(unit) {
  if (length(unit) == 2)
paste(unit[1],^{,unit[2],},sep=)
  else paste(unit,sep=)
  }))
  cat(units, sep=.)
}
expr - V m^-3 kg^-2 l^4
makeUnits(expr) # this works, and produces:

# V.m^{-3}.kg^{-2}.l^{4}
silab - function(..., units=NULL){ # creates a valid  
expression for xlab

and co.
  dotCalls - substitute(list(...))
  nArgs - length(dotCalls)
if (!is.null(units))myUnits - makeUnits(units)
if (!is.null(units)) return(substitute(paste(...,  / ,   
myUnits)))

if (is.null(units)) return(substitute(paste(...)))
}
silab(text, alpha,  units = V m^-3 kg^-2 l^4) # the result is
obviously not what I want
par(mfrow=c(2, 1)) # comparison of the desired output and the  
current one

plot(1:10, 1:10,
  xlab=silab(text , alpha, units = V m^-3 kg^-2 l^4),
  ylab=silab(simple text))
plot(1:10, 1:10,
  xlab=expression(paste(text , alpha,  / , V,., m^ 
{-3}, .,

kg^{-2}, ., l^{4})),
  ylab=simple text)

Any thoughts welcome!
Sincerely,
baptiste
_
Baptiste Auguié
Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto
__
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.


_

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto

__
R-help@r-project.org 

[R] expression, strsplit, ...

2008-06-25 Thread baptiste Auguié

DeaR list,

I'm a bit lost in the behavior of substitute and co.
I often use fairly long axis labels in my graphs (long to write, that  
is). Typically, they would contain some greek letters and units with  
exponents, as in:


	xlab=expression(paste(text , alpha,  / , V,., m^{-3}, .,  
kg^{-2}, ., l^{4}))



To make this a bit prettier, I've attempted to mimic the behavior of  
the SIstyle latex package which defines a macro that cleverly parses  
an expression for units, exponents, etc. My code fails in putting  
together the unit, as seen in the example below:




makeUnits - function(expr){ # formats the units

units.list - strsplit(expr, [[:blank:]], perl=F)
expr.list - strsplit(unlist(units.list), \\^, perl=T)

units - unlist(lapply(expr.list, function(unit) {
if (length(unit) == 2) paste(unit[1],^{,unit[2],},sep=)
else paste(unit,sep=)
}))
cat(units, sep=.)
}

expr - V m^-3 kg^-2 l^4
makeUnits(expr) # this works, and produces:

# V.m^{-3}.kg^{-2}.l^{4}


silab - function(..., units=NULL){ # creates a valid expression  
for xlab and co.

dotCalls - substitute(list(...))
nArgs - length(dotCalls)
if (!is.null(units))myUnits - makeUnits(units)
if (!is.null(units)) return(substitute(paste(...,  / ,  myUnits)))
if (is.null(units)) return(substitute(paste(...)))
}

silab(text, alpha,  units = V m^-3 kg^-2 l^4) # the result is  
obviously not what I want


par(mfrow=c(2, 1)) # comparison of the desired output and the  
current one

plot(1:10, 1:10,
xlab=silab(text , alpha, units = V m^-3 kg^-2 l^4),
ylab=silab(simple text))

plot(1:10, 1:10,
	xlab=expression(paste(text , alpha,  / , V,., m^{-3}, .,  
kg^{-2}, ., l^{4})),

ylab=simple text)





Any thoughts welcome!

Sincerely,

baptiste

_

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto

__
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] expression, strsplit, ...

2008-06-25 Thread Gabor Grothendieck
Try this:

plot(1, xlab = ~ alpha / V * m^-3 * kg ^-2 * l^4)


On Wed, Jun 25, 2008 at 1:06 PM, baptiste Auguié [EMAIL PROTECTED] wrote:
 DeaR list,

 I'm a bit lost in the behavior of substitute and co.
 I often use fairly long axis labels in my graphs (long to write, that is).
 Typically, they would contain some greek letters and units with exponents,
 as in:

xlab=expression(paste(text , alpha,  / , V,., m^{-3}, .,
 kg^{-2}, ., l^{4}))


 To make this a bit prettier, I've attempted to mimic the behavior of the
 SIstyle latex package which defines a macro that cleverly parses an
 expression for units, exponents, etc. My code fails in putting together the
 unit, as seen in the example below:


 makeUnits - function(expr){ # formats the units

 units.list - strsplit(expr, [[:blank:]], perl=F)
 expr.list - strsplit(unlist(units.list), \\^, perl=T)

 units - unlist(lapply(expr.list, function(unit) {
if (length(unit) == 2)
 paste(unit[1],^{,unit[2],},sep=)
else paste(unit,sep=)
}))
cat(units, sep=.)
 }

 expr - V m^-3 kg^-2 l^4
 makeUnits(expr) # this works, and produces:

 # V.m^{-3}.kg^{-2}.l^{4}

 silab - function(..., units=NULL){ # creates a valid expression for xlab
 and co.
dotCalls - substitute(list(...))
nArgs - length(dotCalls)
 if (!is.null(units))myUnits - makeUnits(units)
 if (!is.null(units)) return(substitute(paste(...,  / ,  myUnits)))
 if (is.null(units)) return(substitute(paste(...)))
 }

 silab(text, alpha,  units = V m^-3 kg^-2 l^4) # the result is
 obviously not what I want

 par(mfrow=c(2, 1)) # comparison of the desired output and the current one
 plot(1:10, 1:10,
xlab=silab(text , alpha, units = V m^-3 kg^-2 l^4),
ylab=silab(simple text))

 plot(1:10, 1:10,
xlab=expression(paste(text , alpha,  / , V,., m^{-3}, .,
 kg^{-2}, ., l^{4})),
ylab=simple text)




 Any thoughts welcome!

 Sincerely,

 baptiste

 _

 Baptiste Auguié

 Physics Department
 University of Exeter
 Stocker Road,
 Exeter, Devon,
 EX4 4QL, UK

 Phone: +44 1392 264187

 http://newton.ex.ac.uk/research/emag
 http://projects.ex.ac.uk/atto

 __
 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-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] expression matrix

2008-03-10 Thread Jabez Wilson
Date: Sat, 8 Mar 2008 04:56:58 -0800 (PST)
From: Keizer_71 [EMAIL PROTECTED]
Subject: [R]  expression matrix
To: r-help@r-project.org
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=us-ascii

Hello,

I am to run this R script but i keep getting this error.

 expr-exprs(golubMerge)
Warning message:
The exprSet class is deprecated, use ExpressionSet instead 

I tried to find information on the website but no luck. (exprSet...etc)

thank you.

  You must be very unlucky indeed. Top hit for me with ExpressionSet in 
google was this:
  An Introduction to Bioconductor’s ExpressionSet Class  File Format: 
PDF/Adobe Acrobat - View as HTML
The data in an ExpressionSet is complicated, consisting of expression data from 
mi- ... The ExpressionSet class coordinates all of this data, so that ...
www.bioconductor.org/packages/2.0/bioc/vignettes/Biobase/inst/doc/ExpressionSetIntroduction.pdf
 - Similar pages

   
-

The World #39;s Favourite Email.
[[alternative HTML version deleted]]

__
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] expression matrix

2008-03-08 Thread Martin Morgan
Christophe -- You'll want to coerce golubMerge to an ExpressionSet.

 library(Biobase)
 library(golubEsets)
 data(golubMerge)
 golubUpdated - as(golubMerge, ExpressionSet)
Warning messages:
1: In asMethod(object) :
  missing or mis-shaped 'se.exprs' in original object; creating ExpressionSet 
without se.exprs
2: The phenoData class is deprecated, use AnnotatedDataFrame (with 
ExpressionSet) instead 
3: The phenoData class is deprecated, use AnnotatedDataFrame (with 
ExpressionSet) instead 

The warning messages above can, in this case, be ignored. After this,
everything should be fine, e.g.,

 exprs - exprs(golubUpdated)

Martin

Douglas Bates [EMAIL PROTECTED] writes:

 On Sat, Mar 8, 2008 at 7:00 AM, Keizer_71 [EMAIL PROTECTED] wrote:

  Hello,

  I am to run this R script but i keep getting this error.

   expr-exprs(golubMerge)
  Warning message:
  The exprSet class is deprecated, use ExpressionSet instead

  I tried to find information on the website but no luck. (exprSet...etc)

 I think you want to try the Bioconductor (http://www.bioconductor.org)
 web site instead of the R web site.

 __
 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.

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793

__
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.