Why it always gives me a 3?
> fun=function(x) {
+ if (x<-3) {
+ return(x)
+ } else {
+ if(x<2) {
+ return(x^2-1)
+ } else {
+ return(log(x))
+ }}}
>
> fun(-5)
[1] 3
> fun(0)
[1] 3
> fun(10)
[1] 3
> fun(-10)
[1] 3
>
--
View this message in context: http://r.789695.n4.nabble.com/Problem-with-if-tp4649180.html
Sent from the R help mailing list archive at Nabble.com.