[R] a bug?

Roger Peng rpeng at stat.ucla.edu
Thu Jul 18 03:14:37 CEST 2002


Depending on what exactly f and g do, you might be using the 'if'
statement incorrectly.  For example if f and g are vectorized, and x is a
vector, then 'if(f(x) > g(x))' will produce weird behavior.  In any case,
I don't think your function is vectorized so it won't work in curve()
anyway.

How about try something like:

myFunction <- function(x) pmin(f(x), g(x))

which takes the parallel minimum of f and g.  I think that might be what
you want.

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

On Wed, 17 Jul 2002, Francisco J Molina wrote:

> I am having problems to use the command curve with a function of the
> form
> 
> min ( f ( x ), g ( x ))
> 
> If I try with the function
> 
> myFunction <- function ( x ) if ( f ( x ) > g ( x )) f ( x ) else g ( x
> )
> 
> I also have problems.
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list