I am trying to plot the following function over the range 0-100 test <- function(t){{ if (t<=10) x<-t*0 else x<-2*t } x }
when I use plot(test,0,100) the GUI produces the following; "Warning message: In if (t <= 10) x <- t * 0 else x <- 2 * t : the condition has length > 1 and only the first element will be used" I am confused as when I evaluate the function for individual t it gives the correct response i.e. 0 for t<=10 and 2*t for t>10... This is what I wish the function to do however, I am not able to plot the function. Any help would be most appreciated! -- View this message in context: http://r.789695.n4.nabble.com/Plotting-a-function-that-includes-logical-operators-tp3697732p3697732.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.