Re: [R] Plotting own function

2010-12-07 Thread jim holtman
You need to use 'ifelse' in this case since it will handle a vector and 'if' is only for single values: func <- function(x) { y <- exp(-0.5*((x-63.9)/23.2)^2) ifelse(x > 63.9, 2 - y, y) } x = seq(-10,150,length=500) y <- func(x) plot(x,y,type="l",lwd=2,col="red") On Tue, Dec 7,

[R] Plotting own function

2010-12-07 Thread Tobias Schultze
Hello, I have a simple question but didn't find a solution. How do I plot a custom function. I have defined this function func <- function(x) { y <- exp(-0.5*((x-63.9)/23.2)^2) if(x > 63.9) return(2 - y) else { return(y) } } and wan