[R] Plotting own function

Tobias Schultze webmaster at tubo-world.de
Tue Dec 7 12:57:42 CET 2010

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 {

and want to plot it in a specified range like

x = seq(-10,150,length=500)
y <- func(x)

But it doesn't work because it expects a vector but I need to compare the
scalar x.
How do I do it correctly?

Thanks a lot

More information about the R-help mailing list