Skip to content
Prev 244149 / 398506 Next

Plotting own function

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, 2010 at 6:57 AM, Tobias Schultze <webmaster at tubo-world.de> wrote: