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 want to plot it in a specified range like x = seq(-10,150,length=500) y <- func(x) plot(x,y,type="l",lwd=2,col="red") 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 Tobias ______________________________________________ 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.